Re: How to get PHP to download web contents

From: Date: Thu, 03 Jul 2003 07:54:31 +0000
Subject: Re: How to get PHP to download web contents
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-153836@lists.php.net to get a copy of this message
Steve B. wrote:
How would you get PHP to download a file such as a web page and put it in a string? 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
$fp = fopen("/http://site.com/path/to/file/", "r"); while (!feof($fp)) { $buf .= fread($fp, 1024); } fclose($fp); I like this method more than using file(), just because I have more control over what happens. Since you're reading as its downloading, you can do stuff with the data before you're finished. As for parsing HTML... regular expressions are very cool.

« previous php.general (#153836) next »