python获取代理需要账户和密码代码模板

2020-06-19 12:01:31 浏览数 (1)

代码语言:javascript复制
from urllib import request
#网上很多说的urllib2,在python3中其实就是urllib.request
proxy_support = request.ProxyHandler({'http':'http://username:password@IP:port'})
auth = request.HTTPBasicAuthHandler()
opener = request.build_opener(proxy_support, auth, request.HTTPHandler)
request.install_opener(opener)
response = request.urlopen("你访问的rul")
html = response.read()

0 人点赞