Page 1 of 1

[SOLVED] Reading data from a page on the internet

Posted: Tue Jun 29, 2004 5:34 pm
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.

Posted: Tue Jun 29, 2004 5:44 pm
by feyd
[php_man]curl[/php_man]; you may be able to use [php_man]file_get_contents[/php_man]

Posted: Tue Jun 29, 2004 6:04 pm
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.

Posted: Tue Jun 29, 2004 6:09 pm
by feyd

Code: Select all

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

there's of course the regex ways too..

Posted: Tue Jun 29, 2004 6:17 pm
by evilmonkey
Yes, that does the job perfectly. Thank you for your help :)