首页IT科技using a computer(Using an HTTP PROXY Python Stack Overflow)

using a computer(Using an HTTP PROXY Python Stack Overflow)

时间2025-07-15 10:39:05分类IT科技浏览5484
导读:Using an HTTP PROXY - Python...

Using an HTTP PROXY - Python

You can do it even without the HTTP_PROXY environment variable. Try this sample:

import urllib2proxy_support = urllib2.ProxyHandler({"http":"http://61.233.25.166:80"})opener = urllib2.build_opener(proxy_support)urllib2.install_opener(opener)html = urllib2.urlopen("http://www.google.com").read()print html

In your case it really seems that the proxy server is refusing the connection.

Something more to try:

import urllib2#proxy = "61.233.25.166:80"proxy ="YOUR_PROXY_GOES_HERE"proxies ={"http":"http://%s"% proxy}url ="http://www.google.com/search?q=test"headers={User-agent:Mozilla/5.0}proxy_support = urllib2.ProxyHandler(proxies)opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler(debuglevel=1))urllib2.install_opener(opener)req = urllib2.Request(url,None, headers)html = urllib2.urlopen(req).read()print html

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
在家网上赚钱赚外快网上在家赚钱哪些是骗局-央视曝光三类重点骗局:在家动动手指就能赚钱的“好工作”竟然是… seo网站排名的软件(提升网站排名,选择SEO专业优化公司)