trouble getting google through urllib

Amit Khemka khemkaamit at gmail.com
Wed Dec 20 01:20:39 EST 2006


On 19 Dec 2006 16:12:59 -0800, Dr. Locke Z2A <DocZ2A at gmail.com> wrote:
> I looked at those APIs and it would appear that SOAP isn't around
> anymore and there are no APIs for google translate :(  Can anyone tell
> me how to set the user-agent string in the HTTP header?

import urllib2
req = urllib2.Request('http://www.google.com')
# add 'some' user agent header
req.add_header('User-Agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:1.7.8) Gecko/20050524 Fedora/1.5 Firefox/1.5')
up = urllib2.urlopen(req)

cheers,
amit
-- 
----
Amit Khemka -- onyomo.com
Home Page: www.cse.iitd.ernet.in/~csd00377
Endless the world's turn, endless the sun's Spinning, Endless the quest;
I turn again, back to my own beginning, And here, find rest.



More information about the Python-list mailing list