[SOLVED] Reading data from a page on the internet

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
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

[SOLVED] Reading data from a page on the internet

Post by evilmonkey »

Hello.

I am interested in making a script that scans a certain html page for a certain line and outputting that line in my own script (I want to create a dynamic image). I am familiar with readfile(), but that doesn't do the job very well as it just copies and pastes the whole code in the output buffer. I need a different solution. Can anyone point me in the right direction?

Thanks.
Last edited by evilmonkey on Tue Jun 29, 2004 6:18 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

[php_man]curl[/php_man]; you may be able to use [php_man]file_get_contents[/php_man]
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

file_get_conternts works for me. Also, how can I limit the reading of the string...for example, I use strstr($haystack, $needle), but that gives me everything after $needle. I would like to display 3 characters AFTER $needle (not including $needle iteself). Those 3 characters will always change, but $needle will not. Help please.

Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

substr($contents,strpos($contents, $needle) + strlen($needle),3);
I think.. :)

there's of course the regex ways too..
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Yes, that does the job perfectly. Thank you for your help :)
Post Reply