您的位置:首页 > 编程语言 > Python开发

python HTMLParser代理访问的通用写法

2018-01-23 13:53 148 查看
from urllib import request

proxyConfig="http://%s:%s@%s"%("hui.zhang",'123456','10.110.5.235:8080')

proxyHandler=request.ProxyHandler({'http':proxyConfig})

url='https://www.python.org/events/python-events/'

req=request.Request(url)

opener=request.build_opener(proxyHandler)

with opener.open(req) as f:

    data=f.read().decode('utf-8')
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: