PYTHON代理IP

import urllib.request

url = 'http://www.whatismyip.com.tw/'

proxy_support = urllib.request.ProxyHandler({'HTTP':'180.104.62.22:9000'})

opener = urllib.request.build_opener(proxy_support)
opener.addheaders = [('User-Agent','Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36')]



urllib.request.install_opener(opener)

response = urllib.request.urlopen(url)

html = response.read().decode('utf-8')

print(html)
原文地址:https://www.cnblogs.com/wumac/p/5495151.html