Jacklovely

导航

 

说明:

1. 好像是这个网站的代理http://www.xicidaili.com/

2. 第2,3行的模块不用导入,之前的忘删了。。

3. http://www.whatismyip.com.tw/这个网站可以查看本机ip

4. 指定代理,创建代理,安装代理,打开链接,over。。

5. urllib.request.ProxyHandler({"http":"110.72.20.12:8123"}) -> urllib.request.build_opener -> request.install_opener -> urllib.request.urlopen

 1 import urllib.request
 2 import urllib.parse
 3 import json
 4 
 5 iplist = ["110.72.20.12:8123","180.76.154.5:8888"]
 6 proxies = {
 7   "http": "http://10.10.1.10:3128",
 8   "https": "http://10.10.1.10:1080",
 9 }
10 url = "http://www.whatismyip.com.tw/"
11 # url = "http://www.tuwenclub.com"
12 
13 proxy_support = urllib.request.ProxyHandler({"http":"110.72.20.12:8123"})
14 opener = urllib.request.build_opener(proxy_support)
15 opener.addheaders = [("User-Agent","Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.22 Safari/537.36 SE 2.X MetaSr 1.0")]
16 urllib.request.install_opener(opener)
17 response = urllib.request.urlopen(url)
18 html = response.read().decode("utf-8")
19 
20 print(html)

 

posted on 2017-03-05 23:35  Jacklovely  阅读(528)  评论(0编辑  收藏  举报