PHP and Curl (CURLOPT_RANGE - not working)



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

.



Relevant Pages

  • Re: Information retrieval functions
    ... I assume this works to retrieve the numbers on specified dates ... How do you adjust the formula to pull that out? ... I work in a laboratory that tests patients for genetic abnormalities and ...
    (microsoft.public.excel.worksheet.functions)
  • Constructor API opinions
    ... from a web page identified by id, and stores the object in a database. ... A different part of the system uses the same class to retrieve ... Or, have two different constructors: ... and it's not immediately apparent that pull() ...
    (comp.lang.perl.misc)
  • RE: Help with retrieving data from a table
    ... But is there a generic formula that would pull the value for any code 1 thru ... "Jacob Skaria" wrote: ... The above is a table of information which I wish to retrieve to sheet 2. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Almost herself
    ... desk to retrieve her, as she managed to pull the old I-weigh-50-pounds trick. ... After her first antibiotic she took to her food with gusto i hadn't seen in a ...
    (rec.pets.cats.anecdotes)
  • Re: The Violence Project - a *real* study & statistics on "the street"
    ... Fraser Johnston wrote: ... >>> it, grab his wrist, pull back with your right as you pivot right. ... >> order to bend the elbow. ...
    (rec.martial-arts)