Re: Re: How to get PHP to download web contents
| From: | Ognyan Bankov | Date: | Mon, 07 Jul 2003 06:58:11 +0000 |
| Subject: | Re: Re: How to get PHP to download web contents | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-29119@lists.php.net to get a copy of this message | ||
"Steve B." <stylinsty@yahoo.com> wrote in message
news:20030703233946.58370.qmail@web41505.mail.yahoo.com...
> Hi Nadim,
> It works but not for sites with password window that pops up.
I see.
That is HTTP Basic Authentication
You should use this line:
$filename = 'http://someuser:somepwd@somesite.com/';
instead of:
$filename = "http://somesite.com?user=someuser&pwd=somepwd;
and source will look like:
<?php
// get contents of a file into a string
$filename = 'http://someuser:somepwd@somesite.com/';
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
fclose ($handle);
?>
nadim's solution will look like this:
$html = implode ('', file ('http://someuser:somepwd@somesite.com/'));