Page 1 of 1
download data from other sites
Posted: Thu Apr 21, 2005 1:40 am
by psychotomus
How can I download web pages with php? I want to download the web pages using php then display them. Anyone know how?
Posted: Thu Apr 21, 2005 1:55 am
by psychotomus
nevermind. found out fopen can do it.
Posted: Thu Apr 21, 2005 2:01 am
by hongco
keep in mind that you only see html part, not the php codes of a page.
Posted: Thu Apr 21, 2005 2:02 am
by psychotomus
how can I see all?
Posted: Thu Apr 21, 2005 2:11 am
by hongco
you can't unless you want to hack them or write them a nice letter asking for the code.
Posted: Thu Apr 21, 2005 2:13 am
by Chris Corbyn
psychotomus wrote:how can I see all?
You can't ever view the PHP if PHP is installed correctly and the script is served by HTTP.
Also, fopen() wont work all the time... some sites will reject you for not sending the User-Agent: header.
As I have found froma recent project, fsockopen() does the job much better and you can spoof the script as whatever browser you like....
Even better - use cURL

Posted: Thu Apr 21, 2005 2:15 am
by psychotomus
cant i connect to the site as if my php script was a browser and get all the contents then display it?
Posted: Thu Apr 21, 2005 2:29 am
by Chris Corbyn
psychotomus wrote:cant i connect to the site as if my php script was a browser and get all the contents then display it?
You still wont get the PHP code...
The PHP will have been parsed by the time it reaches your browser.
In terms of making the script look like a browser,
cURL does it pretty well. Next inline,
fsockopen() with the correct headers