Parsing News From Php.net

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
fatal
Forum Contributor
Posts: 118
Joined: Sat Apr 20, 2002 10:47 am
Location: East Coast

Parsing News From Php.net

Post by fatal »

I want to make a custom start page for my computer which would display Php News, amongst them i want the news from Php.net. But i have no idea on how to start this. Is there any functions i should look at? Im thinking of using Regular Expression, is there anything else?

Thanks
Anthron
Forum Newbie
Posts: 8
Joined: Mon May 20, 2002 6:25 pm
Location: usa
Contact:

Post by Anthron »

if i'm correct, you'll need to use fopen() and fread() to open up php.net and read the news off their website.

also, when you use fread(), you'll need a number for the number of bytes to read. just make that number 99999999.

so that'll give you the webpage in a variable. From that you'll need to cut out all the excess html. I would try adding all of the excess header html to a file like excess_header.htm and the same to footer (excess_footer.htm). Then open up those files and add them to a variable. Then you can do a regular expression and end up with just the news html.

after that, a few loops and more regular expressions you should have your news.

Of course, I'm not sure if you already knew most of that.
MattF
Forum Contributor
Posts: 225
Joined: Sun May 19, 2002 9:58 am
Location: Sussex, UK

Post by MattF »

Or you could look to see if they have an XML thingy of their news and if they don't you could suggest one.......
User avatar
enygma
Site Admin
Posts: 175
Joined: Fri Apr 19, 2002 8:29 am
Location: Dallas, Tx

Post by enygma »

I don't think the PHP.net site has an XML feed.....it'd be nice if they did, though.

Otherwise, you're just going to have to either fopen or file it (depending on which you want more - a string or an array). Then, use regexps or something to pick out the headlines.

You better hope they keep it pretty standardized.....
User avatar
fatal
Forum Contributor
Posts: 118
Joined: Sat Apr 20, 2002 10:47 am
Location: East Coast

Post by fatal »

I can only hope :)
Post Reply