Re: How to get PHP to download web contents
| From: | Ognyan Bankov | Date: | Thu, 03 Jul 2003 07:15:47 +0000 |
| Subject: | Re: How to get PHP to download web contents | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-29090@lists.php.net to get a copy of this message | ||
"Steve B." <stylinsty@yahoo.com> wrote in message
news:20030703065739.27186.qmail@web41509.mail.yahoo.com...
> How would you get PHP to download a file such as a web page and put it in
a string?
Try this:
<?php
// get contents of a file into a string
$filename = "http://somesite.com?user=someuser&pwd=somepwd";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
fclose ($handle);
?>
$contents is disired string variable.
Best regards,
Ognyan
>
> What keywords would relate to this (besides php download)
>
> I need a user to be able to put in a name and pass and have PHP go to a
cetain site.
> The site can take the user/pass in the url so I do not need a form submit.
> Then I need the site contents to be in a php variable.
> Any tips on parsing html out of it would be great.
>
> Thanks
>
>
>
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com