Re: How to catch the output of http:// -> text file?
| From: | Wieger Uffink | Date: | Thu, 03 May 2001 16:08:12 +0000 |
| Subject: | Re: How to catch the output of http:// -> text file? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-51287@lists.php.net to get a copy of this message | ||
Hi Simon,
Try the following for reading the files,
for(i=1;i<2000;i++) {
$response="";
$request="kbid=$i";
//Header
$header = "POST kb.html HTTP/1.0\r\n";
$header .= "Content-type: application/x-www-form-urlencoded\r\n";
$header .= "Content-length: " . strlen($request) . "\r\n\r\n";
//Open Connection
$fp = fsockopen("www.mysite.com",80,&$err_num,&$err_msg, 30);
if($fp) {
fputs($fp, $header.$request);
while(!feof($fp))
$response .= fgets($fp,2048);
fclose($fp);
}
else {
if(DEBUG) {
echo "ERR_NUM: $err_num\nERR_MSG: $err_msg";
}
//write response to a file
echo $response;
}
Hope this helps you,
Wieger
Kraa de Simon wrote:
>
> Hi,
>
> PHP newbie.
>
> Can anyone help me with the following?
>
> Pseudo code:
>
> for(i=1;i<2000;i++)
> {
> catch the output of
> http://www.mysite.com/kb.html?kbid= <? echo
> i ?>
> and put the html code in a text file called
> /www/kb/kbid <? echo i ?> .html
> }
>
> So the end result is 2000 html files on disk "extacted" from the
> http://
> address...
>
> Thanks...
>
> Met vriendelijke groet / With kind regards,
>
> Simon de Kraa
> ICL Logistic Systems
> mailto:Simon.de.Kraa@icl.nl
>
> ---
>
> Microsoft Windows 2000 Professional SP 1, Progress 9.1b, Roundtable 9.1b
> SCO UnixWare 7.1.1, Progress 9.1a11
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
Wieger Uffink
tel: +31 20 428 6868
fax: +31 20 470 6905
web: http://www.usmedia.nl