URLLIb2 problem

Jerry Hill malaclypse2 at gmail.com
Mon Jun 30 22:29:59 CEST 2008

On Mon, Jun 30, 2008 at 4:11 PM,  <leechat2001 at gmail.com> wrote:
> I am trying to write somecode of this kind :)
> opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
> opener.addheaders = [
> ('Accept-Encoding','gzip,deflate'),
> urllib2.install_opener(opener)
> fu = urllib2.urlopen('http://www.google.com')
> print fu.read()
> I am not able to open any webpage as the content is junk
> characters.something like below..what could be the
> problem?????????????

You told the website that you would accept gzip encoded data, and it
looks like the website decided to send you some.  You need to either
take that header out of your opener, or actually handle the gzipped
data that's being sent back to you.


More information about the Python-list mailing list