Re: using curl to get part of the html

From: Date: Fri, 25 Oct 2002 12:14:21 +0000
Subject: Re: using curl to get part of the html
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-121417@lists.php.net to get a copy of this message
You have the page in $result, so you need $result=explode("\n",$result), and echo $result[0] - [99] Patrick Hsieh wrote:
Hello list, I am writing a php script to fetch a html page and verify its content which generated by a remote cgi program. The special cgi program generates endless content to the http client. Therefore, I need to figure out a solution for curl to fetch part of the html source code(In fact, I only need the first 100 lines of the html source). I tried CURLOPT_TIMEOUT, but when curl_exec() timeouts, it will not return part of the html source it already fetched--actually it returns nothing at all. Is there any way to work around this? #!/usr/bin/php4 -q <?php $url = "http://www.example.com/cgi-bin/large_output.cgi"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 3); $result = curl_exec($ch); curl_close($ch); echo $result; ?>


« previous php.general (#121417) next »