Is it possible do only download a portion of a binary file
A small question concerning downloading xml files from a remote server. I am using curl to achieve this.
The information I need in those xml files a开发者_开发问答re located in the first couple of lines of code. Now my question is :
Is it possible to download only a portion ( or a defined amount of bytes ) from these xml files , so I only have the first (let's say) 30 lines.
Those xml files are between 100 kb to 12 mb , so you understand that it would be more efficient to be able to minimize the bandwith of the curl request ( I'm talking about 1000 xml files a day at least ).
Thanks
Check out the --range option for cURL, which lets you do just that.
For HTTP, this will require the remote server to honour HTTP/1.1 Range requests - for example, if you specify a range -r0-10 then the following header will be transmitted
Range: bytes=0-10
If server doesn't want to honour that, it will return the entire file.
精彩评论