Forum Moderators: coopster

Message Too Old, No Replies

PHP for getting page content

getting page content from another site

         

haryanto

5:26 pm on Apr 29, 2004 (gmt 0)

10+ Year Member



Guys,

I wanted to try to get content from a page say www.google.com and use PHP to modify it to my liking.

Don't worry I am not using this for malicious purpocses.

Is there any tutorial on the net regarding this?
I heard I ahve to use epreg_replace and what not....

WhosAWhata

6:30 pm on Apr 29, 2004 (gmt 0)

10+ Year Member



basically you can use cURL [php.net] to capture the html output of any page in a variable

then use ereg_replace [php.net] or preg_replace [php.net] to change them
the documentation in the links should give you a start

coopster

7:31 pm on Apr 29, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Another option besides cURL are a couple of PHP File System functions. file_get_contents [php.net] reads an entire file into a string, file [php.net] reads an entire file into an array.

You can use a URL as a filename with these functions if the fopen wrappers [php.net] have been enabled.

WhosAWhata

4:07 am on Apr 30, 2004 (gmt 0)

10+ Year Member



while i agree, and often use file_get_contents,
i've found that cURL is much more reliable

jamesa

4:21 am on Apr 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yea there's a few of ways to do that. Here's another one:

$thehtml = include ("http://www.google.com");
//your stuff here
echo $thehtml;