Deflate with urllib2...

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Sep 10 03:50:18 EDT 2008


En Tue, 09 Sep 2008 16:38:54 -0300, Sam <samslists at gmail.com> escribió:

> I'm using urllib2 and accepting gzip and deflate.
>
> It turns out that almost every site returns either normal text or
> gzip.  But I finally found one that returns deflate.
>
> Here's how I un-gzip:
>    compressedstream = StringIO.StringIO(data)
>    gzipper = gzip.GzipFile(fileobj=compressedstream)
>    data = gzipper.read()
>
> Un-gzipping works great!
>
> Here's how I un-deflate  (inflate??)
>    data = zlib.decompress(data)
>
> Un-deflating doesn't work.  I get "zlib.error: Error -3 while
> decompressing data: incorrect header check"
>
> I'm using python 2.5.2.  Can someone tell me exactly how to handle
> deflated web pages?

zlib.decompress should work - can you provide a site that uses deflate to  
test?

-- 
Gabriel Genellina




More information about the Python-list mailing list