faqts : Computers : Programming : Languages : PHP : Function Libraries

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

60 of 67 people (90%) answered Yes
Recently 9 of 10 people (90%) answered Yes


How can I get data from another web page into PHP?
Can I retrieve an external web page using PHP?

Jul 2nd, 2000 16:56
Philip Olson, Nathan Wallace, Jim Winstead, Manual Lemos

You can download a web page from another site using
    fopen("http://...", "r")
But you should look at whether that site allows you to do what you want.
It may not if they make their money by serving up banner ads on the
pages they serve up for you.
If you need to get the page via a proxy or using POSTed forms, check
Another way to do it is this :
   $url = 'http://www.iloveyoursite.com/index.php';
   $lines_array = file($url);
   $lines_string = implode('', $lines_array);
   eregi("<html>(.*)</html>", $lines_string, $mydata);
   echo $mydata[0];
$url = the site your gathering your data from
$mydata = the newly harvested data
<html> and </html> are the first and last items on the $url, you can 
replace this with anything.  like, if you're wanting their body you may 
choose <body> and </body> or anything works...doesn't have to be an 
html tag, just a beginning and end.  of course these should actually 
exist within the $urls page.  
this will put the page within your website quite nicely and have fun!