How to grab a part of web page?

William Park opengeometry at NOSPAM.yahoo.ca
Tue Jul 9 22:35:53 EDT 2002


Fredrik Lundh <fredrik at pythonware.com> wrote:
> "A" <printers at sendme.cz> wrote:
>> Is it possible to download only a part of web page?
>> Say I need to find out an information about a customer that starts
>> at 1500 byte position and ends at 2000 byte position. If the whole
>> page has about 100 kb it seems to me waste of time to load all the
>> page.
> 
> import urllib
> 
> file = urllib.urlopen(DATA)
> data = file.read(2000)
> file.close()
> 
> print data[1500:2000]

What if it's the last 500 bytes that he wants?

-- 
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
8-CPU Cluster, Hosting, NAS, Linux, LaTeX, python, vim, mutt, tin



More information about the Python-list mailing list