Proxy with urllib2

前端 未结 7 1547
借酒劲吻你
借酒劲吻你 2020-11-22 17:15

I open urls with:

site = urllib2.urlopen(\'http://google.com\')

And what I want to do is connect the same way with a proxy I got somewhere telli

7条回答
  •  渐次进展
    2020-11-22 17:40

    You have to install a ProxyHandler

    urllib2.install_opener(
        urllib2.build_opener(
            urllib2.ProxyHandler({'http': '127.0.0.1'})
        )
    )
    urllib2.urlopen('http://www.google.com')
    

提交回复
热议问题