PHP and Curl (CURLOPT_RANGE - not working)
- From: igrigorik@xxxxxxxxx
- Date: 19 Aug 2006 09:00:38 -0700
Hi,
I'm trying to pull a remote page to retrieve some data from it and I'd
like to only grab a section of the site as opposed to retrieving the
entire document and then processing it (full file is about 19kb, i only
need about 5% of that data).
Now, I've found the CURLOPT_RANGE variable in php-doc but it doesnt
seem to do anything, I'm still getting the entire body of the page when
I run with it enabled. Here is a sample of my code:
function processURL($url){
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RANGE, "0-4096");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return to var
curl_setopt($ch, CURLOPT_FAILONERROR, 1); // dont hang
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // time out after
3s
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec ($ch);
curl_close ($ch);
echo $data;
return $data;
}
It's only supposed to pull the first 4kb with that code, but I'm
getting the entire page. Am I missing something?
Thanks.
Ilya
.
- Follow-Ups:
- Re: PHP and Curl (CURLOPT_RANGE - not working)
- From: igrigorik
- Re: PHP and Curl (CURLOPT_RANGE - not working)
- Prev by Date: Re: does PEAR auth expects the username & password encrypted in the database?
- Next by Date: Re: PHP and Curl (CURLOPT_RANGE - not working)
- Previous by thread: PHP and VMware: SLOW
- Next by thread: Re: PHP and Curl (CURLOPT_RANGE - not working)
- Index(es):
Relevant Pages
|