【问题标题】:How to use proxie to open 'https' website by urllib?如何使用代理通过 urllib 打开“https”网站?
【发布时间】:2016-03-31 12:02:06
【问题描述】:
proxy_support=urllib.request.ProxyHandler({'http':random.choice(iplist)})
opener=urllib.request.build_opener(proxy_support)
urllib.request.install_opener(opener)
但是如果我用它打开一个“https”网站,它不使用代理。如何修复它?
【问题讨论】:
标签:
python
python-3.x
web-crawler
urllib
【解决方案1】:
proxy_support=urllib.request.ProxyHandler({'http':random.choice(iplist)})
您只为http 提供了代理。
对于带有https 的网站,您需要单独的代理。
urllib.request.ProxyHandler({'http':random.choice(iplist), 'https': "https://host:port'})