Page 1 of 1
downloading source code of an external website
Posted: Mon Aug 03, 2009 2:54 am
by bucz
hello,
my question is: how, using php, download source code of an external webpage? i have an url
http://www.example.com/index.php?show=0123 and if I pass it to the file() function, it kicks back an error. I belive that it is because i use arguments in url (that are nececitary). is there something similat to linux
Code: Select all
wget -O - http://www.example.com/index.php?show=0123
?
Re: downloading source code of an external website
Posted: Mon Aug 03, 2009 5:17 am
by onion2k
To do that in PHP the URL wrapper option in PHP.ini has to be enabled .. if it is then file(), file_get_contents(), etc will all work. If it's not then you could alternatively use shell() or exec() with wget.
It's obvious, but in case you're not aware it will download the HTML source, not the PHP/Perl/ASP/whatever. You can't get that.
Re: downloading source code of an external website
Posted: Mon Aug 03, 2009 6:03 am
by bucz
thanks for a fast response
well, it is not my server and i am afraid that i cannot play with php.ini configuration... and what if i cannot exec anything as well? is there any php procedure that would work here?
Re: downloading source code of an external website
Posted: Mon Aug 03, 2009 6:12 am
by onion2k
bucz wrote:well, it is not my server and i am afraid that i cannot play with php.ini configuration... and what if i cannot exec anything as well? is there any php procedure that would work here?
You could try curl(), or fsockopen(), but they're both going to be a lot more complicated than things like file_get_contents(), and they probably won't work if the server is locked down properly.