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)

 

posted @ 2016-05-15 13:58  疯陈演义  阅读(223)  评论(0编辑  收藏  举报