如何使用proxie打开' https' urllib的网站?

时间:2016-03-31 12:02:07

标签: python python-3.x web-crawler urllib

proxy_support=urllib.request.ProxyHandler({'http':random.choice(iplist)})
opener=urllib.request.build_opener(proxy_support)
urllib.request.install_opener(opener)

但是,如果我用它打开一个' https'网站,它不使用proxies.How修复它?

1 个答案:

答案 0 :(得分:1)

proxy_support=urllib.request.ProxyHandler({'http':random.choice(iplist)})

您只为http提供了代理。 对于https的网站,您需要单独的代理。

urllib.request.ProxyHandler({'http':random.choice(iplist), 'https': "https://host:port'})