Re: URLLIb2 problem



On Jun 30, 9:11 pm, leechat2...@xxxxxxxxx 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}|α



Relevant Pages

  • Re: Diana Saba FAQ ~ July 2006
    ... It WAS fun, wasn't it?!? ... I had done very limited programming in ISQL/ESQL, ... creating/improving his/her webpage with the help of htmlgoodies.com... ... nice kid) had morphed to look completely unlike me, ...
    (alt.med.fibromyalgia)
  • Re: Java redirecting url
    ... I have been using an embedded java program "FreedomAudio" in a webpage. ... But on a new install it looks for a webpage at "http://www.freedomaudio.com/install ... ... Install a web proxy and configure your web-browser to use the proxy then configure the proxy to do the redirection. ...
    (comp.lang.java.help)
  • Amavis-stats Not working
    ... I installed the amavis-stats port so I can produce ... I installed it with 'make install clean' and ... The webpage shows but it shows the following errors under Daily, Weekly, ... that specific tool on FreeBSD. ...
    (freebsd-questions)
  • Re: Java redirecting url
    ... But on a new install it looks for a webpage at "http://www.freedomaudio.com/install ... ... Lets say you want to redirect http://www.freedomaudio.com/install/whatever to http://www.yoursite.com/install/whatever and that the IP-address of www.yoursite.com is 123.45.67.89 ... Install a web proxy and configure your web-browser to use the proxy then configure the proxy to do the redirection. ...
    (comp.lang.java.help)
  • Re: Help Desk App - Need ideas or directions
    ... A webpage is meant to show what is on a server and not visa versa. ... install the websites online. ... software as your computers are also used to go to internet. ...
    (microsoft.public.dotnet.languages.vb)