How to grab a part of web page?

Gerhard Häring gerhard.haering at gmx.de
Tue Jul 9 23:16:01 EDT 2002


* Fredrik Lundh <fredrik at pythonware.com> [2002-07-09 23:04 +0000]:
> "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 about implementing seek() on the file-like object? Wasn't this
hotly discussed already a few month (years) ago? I wonder why it hasn't
ended up in urllib, yet.

Gerhard
-- 
This sig powered by Python!
Außentemperatur in München: 17.5 °C      Wind: 1.7 m/s





More information about the Python-list mailing list