urllib2使用代理服务器

urllib2使用代理服务器,第1张

概述urllib2使用代理服务器

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

# The proxy address and port:proxy_info = { 'host' : 'proxy.myisp.com','port' : 3128             } # We create a handler for the proxyproxy_support = urllib2.ProxyHandler({"http" : "http://%(host)s:%(port)d" % proxy_info}) # We create an opener which uses this handler:opener = urllib2.build_opener(proxy_support) # Then we install this opener as the default opener for urllib2:urllib2.install_opener(opener) # Now we can send our http request:HTMLpage = urllib2.urlopen("http://sebsauvage.net/").read(200000) #如果代理需要验证proxy_info = { 'host' : 'proxy.myisp.com','port' : 3128,'user' : 'John Doe','pass' : 'mysecret007'             }proxy_support = urllib2.ProxyHandler({"http" : "http://%(user)s:%(pass)[email protected]%(host)s:%(port)d" % proxy_info})opener = urllib2.build_opener(proxy_support)urllib2.install_opener(opener)HTMLpage = urllib2.urlopen("http://sebsauvage.net/").read(200000)

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的urllib2使用代理服务器全部内容,希望文章能够帮你解决urllib2使用代理服务器所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1198615.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存