Форум сетевых администраторов
Показаны 2 сообщений на этой странице

Форум сетевых администраторов (http://netadmin.ws/forum/index.php)
- PHP (http://netadmin.ws/forum/forumdisplay.php?forumid=6)
-- еще раз к вопросу о граббере (http://netadmin.ws/forum/showthread.php?threadid=8650)


Помещено galantov 04-05-2004 в 05:22:

еще раз к вопросу о граббере

следующая конструкция

<?
$fd= fread(fopen("http://ishim.info", "r"), 100000);

if ($fd)
{
$start= strpos($fd, "<html>");
$finish= strpos($fd, "<\/html>");
$length= $finish-$start;
$code=Substr($fd, $start, $length);
}


echo $code;

?>

результат
у меня возникает ощущение что есть какой то таймаут, потому как виден лишь кусок страницы .... проверял на двух хостингах.

многие говорят что работать должно без проблем....
в чем ошибка?


Помещено SCHIZO 05-05-2004 в 08:21:

http://www.php.net/manual/en/function.fread.php

quote:

Warning
When reading from network streams or pipes, such as those returned when reading remote files or from popen() and fsockopen(), reading will stop after a packet is available. This means that you should collect the data together in chunks as shown in the example below.

PHP:

<?php
$handle 
= fopen("http://www.example.com/", "rb");
$contents = '';
while (!
feof($handle)) {
  
$contents .= fread($handle, 8192);
}
fclose($handle);
?>


Note: If you just want to get the contents of a file into a string, use file_get_contents() as it has much better performance than the code above.

__________________
FAQ OFF


Формат времени GMT. Текущее время 13:04.
Показаны 2 сообщений на этой странице

Powered by: vBulletin Version 2.2.4
Copyright © Jelsoft Enterprises Limited 2000, 2001.