[Python]爬取IP代理

 1 #!/usr/bin/env python
 2 # -*- coding: utf-8 -*-
 3 
 4 import re
 5 import requests
 6 #from bs4 import BeautifulSoup
 7 #sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
 8 XiCi_List = []
 9 XiCi_Html = requests.get("http://www.yun-daili.com")
10 # print(XiCi_Html.text)
11 ip_list = r'style[1,2]">\b(.*?)</td'
12 #ip_cont = r'style2">\b(.*?)</td'
13 ip_style = re.findall(ip_list, XiCi_Html.text, re.S)
14 #ip_wcon = re.findall(ip_cont, XiCi_Html.text, re.S)
15 # print(ip_style)
16 for ip_count in range(0, len(ip_style), 2):
17     ip_net = ip_style[ip_count]
18     ip_con = ip_style[ip_count + 1]
19     XiCi_List.append(ip_net + ':' + ip_con)
20 print(XiCi_List)
21 # print(ip_wcon)
22 """
23 et = 0
24 for ip in ip_wnet[range(1, len(ip_wnet), 2)]:
25     #i = re.sub('', '', ip)
26     XiCi_List.append(ip)
27     print(i.strip())
28     et += 1
29 print(XiCi_List)
30 """

 

posted @ 2018-07-20 16:21  陌路不归  阅读(99)  评论(0编辑  收藏  举报