On Jun 30, 9:11 pm, [EMAIL PROTECTED] wrote:
> I am trying to write somecode of this kind :)
>
> opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
> opener.addheaders = [('User-Agent','Mozilla/5.0 (Windows; U; Windows
> NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14'),
> ('Accept','text/xml,application/xml,application/xhtml+xml,text/
> html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'),('Accept-
> Language','en-us,en;q=0.5'),('Accept-Encoding','gzip,deflate'),
> ('Accept-Charset','ISO-8859-1,utf-8;q=0.7,*;q=0.7'),('Keep-
> Alive','300'),('Connection','keep-alive'),('Content-Type','application/
> x-www-form-urlencoded')]
> 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?????????????

I think you'll find that the problem is caused by this part:

('Accept-Encoding','gzip,deflate')

You may also find that these cause you some fun as well.

('Keep-Alive','300'),('Connection','keep-alive')

Michael Foord
http://www.ironpythoninaction.com/
http://www.trypython.org/


>
> if I don't install the 'opener' I get everything properly
>
> φ]δs┌H╢ £T═ ╨Cj2ª╓↑äx:&╖ █c▀╡‼»φÖ╠~J    ►á▒É↑I°▒w≈⌂┐┐╙▌ÆZB┬╪q↕∞
> ¥T9↕R½▼º╗╧√£■ß⌡▐4
> ╧7âÄσ╗ÑV½▐.ià¿"╟ÿÖ¥éτ♫▄└W>╢
> £æy╗=vm█╜)╝▀♂¼└6▀ƒyεƒ♂╙☼╪Ñ9£▓╖╞l■Ä⌡▬>δ╗│üσÿú╜▓(╖g[╬§≤
> L╗S╕╕ⁿτ╔┴┼╤┴┴eü♣Φƒ∞╓╨GcS╧∟w
> s╫♂♀█/☼«Gµ╝|δ█ü9¢█F`·σëφ♫≡*╕│═↔·BV,╛│£í╜↑íöo→▐pzn·♂;≡y9╤4
> ╬ƒÜf░╘⌠πz8ù├▼b╕n▓ºK}|α

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to