Getting source from protected site
Posted: Sun Dec 03, 2006 8:29 am
Hello,
I’m trying to get a page source from a site.
I’m using a simple script :
It works for the usual cases.
The problem I have is that I want to retrieve the information from a page that is on a site that I must enter my login credential first. Then I get only part of the page and not all the information as if I didn’t login.
I’m not trying to hack the page- it’s my information in it, but I want it copied to another place.
I tried adding the username and password to the fopen call :
fopen("http://username:password@example.com ", "rb");
But it didn’t work.
Any help would be appreciated.
Thanks,
Alon
I’m trying to get a page source from a site.
I’m using a simple script :
Code: Select all
<?php
$handle = fopen("http://example.com ", "rb");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
print ($contents);
fclose($handle);
?>It works for the usual cases.
The problem I have is that I want to retrieve the information from a page that is on a site that I must enter my login credential first. Then I get only part of the page and not all the information as if I didn’t login.
I’m not trying to hack the page- it’s my information in it, but I want it copied to another place.
I tried adding the username and password to the fopen call :
fopen("http://username:password@example.com ", "rb");
But it didn’t work.
Any help would be appreciated.
Thanks,
Alon