Hi There
I would like to know if it's possible in PHP to read and take some part off the information inside a web site, like test.com/test.html and display only a part of the information to test2.com/test2.php ???
Or taking the code of a form from test.com/test.php and display the result or a part of the result to test2.com/test2/php ?
Thanks
I would like to read a web page from another site
Moderator: General Moderators
-
TheBentinel.com
- Forum Contributor
- Posts: 282
- Joined: Wed Mar 10, 2004 1:52 pm
- Location: Columbus, Ohio
Re: I would like to read a web page from another site
Look into file_get_contents($url) and the string functions. You'll need something like:jalapenos wrote:Hi There
I would like to know if it's possible in PHP to read and take some part off the information inside a web site, like test.com/test.html and display only a part of the information to test2.com/test2.php ???
Or taking the code of a form from test.com/test.php and display the result or a part of the result to test2.com/test2/php ?
Thanks
Code: Select all
$url = "http://cnn.com";
$html = file_get_contents($url);
print ($html);Hope that helps!
-
TheBentinel.com
- Forum Contributor
- Posts: 282
- Joined: Wed Mar 10, 2004 1:52 pm
- Location: Columbus, Ohio
Thanks for mentioning this. file_get_contents -- while temptingly easy to use -- does indeed fail too often for comfort. It seems that if it works, then it works. Like CNN, for example, always seems to work. But microsoft.com doesn't. Something to do with their redirect? I don't know.patrikG wrote:You may also want to explore the [php_man]CURL[/php_man] library (default library with PHP) - file_get_contents doesn't always work reliably.
Anyway, thanks for that!