Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Top Posters

Who's Online (0)

Powered by Vanilla. Made with Bootstrap.
Python Urllib2 Help
  • Xin
    Posts: 3,251

    url = ('http://www.google.co.uk/#sclient=psy&hl=en&q=test]&aq=f&aqi=g4g-o1&aql=&oq=&pbx=1&fp=1d3db6eacb0cad36')
    opener = urllib2.build_opener(url)
    opener.addheaders = [('User-agent', 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)')]
    data = opener.open(url).read()

    print data


    The source it returns isnt the source of the results, just the google main page :S i dont know why
    Xin
  • Xin
    Posts: 3,251
    Its not the url the url has the same output for both its a urllib problem.
    Xin
  • chroniccommand
    Posts: 1,389
    Well I tried this on my system and got this error:

    TypeError: expected BaseHandler instance, got <type 'str'>
  • Xin
    Posts: 3,251
    Oh wait yeah its urllib2.open(url) im using now as i got that weird error too. The python docs for urllib2 is pretty weak if you ask me. Cant get this stupid thing to work lol.
    Xin