How can I open an URL with a variable and key values in it in Python? I tried as below, but I got a 400 bad request. Opening the file (host) in my web browser doesn't seem to be any problem though. Perhaps the proxy?
for verb in verbs:
host = 'http://google.no/blabla?text=' + verb + '&pos=Any'
checktext = '<font color="maroon">' + verb + '</font>'
params = {'http': 'http://www.someproxy.com:3128'}
req = urllib2.Request(host, urllib.urlencode(params))
res = urllib2.urlopen(req)
print res.read()
NB: Got it. When I put None in as second argument in req (urllib.urlencode(params)), it works. So, it must be the proxy the server does not like.