|
@@ -163,25 +163,42 @@ class Crawler(object, metaclass=ProxyMetaclass):
|
|
|
# adress_port = adress+':'+port
|
|
# adress_port = adress+':'+port
|
|
|
# yield adress_port.replace(' ','')
|
|
# yield adress_port.replace(' ','')
|
|
|
|
|
|
|
|
- def crawl_xicidaili(self):
|
|
|
|
|
- for i in range(1, 3):
|
|
|
|
|
- start_url = 'http://www.xicidaili.com/nn/'.format(i)
|
|
|
|
|
- headers = {
|
|
|
|
|
- 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
|
|
|
|
|
- 'Cookie':'_free_proxy_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJWRjYzc5MmM1MTBiMDMzYTUzNTZjNzA4NjBhNWRjZjliBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMUp6S2tXT3g5a0FCT01ndzlmWWZqRVJNek1WanRuUDBCbTJUN21GMTBKd3M9BjsARg%3D%3D--2a69429cb2115c6a0cc9a86e0ebe2800c0d471b3',
|
|
|
|
|
- 'Host':'www.xicidaili.com',
|
|
|
|
|
- 'Referer':'http://www.xicidaili.com/nn/3',
|
|
|
|
|
- 'Upgrade-Insecure-Requests':'1',
|
|
|
|
|
- }
|
|
|
|
|
- html = get_page(start_url, options=headers)
|
|
|
|
|
|
|
+ # def crawl_xicidaili(self):
|
|
|
|
|
+ # for i in range(1, 3):
|
|
|
|
|
+ # start_url = 'http://www.xicidaili.com/nn/{}'.format(i)
|
|
|
|
|
+ # headers = {
|
|
|
|
|
+ # 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
|
|
|
|
|
+ # 'Cookie':'_free_proxy_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJWRjYzc5MmM1MTBiMDMzYTUzNTZjNzA4NjBhNWRjZjliBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMUp6S2tXT3g5a0FCT01ndzlmWWZqRVJNek1WanRuUDBCbTJUN21GMTBKd3M9BjsARg%3D%3D--2a69429cb2115c6a0cc9a86e0ebe2800c0d471b3',
|
|
|
|
|
+ # 'Host':'www.xicidaili.com',
|
|
|
|
|
+ # 'Referer':'http://www.xicidaili.com/nn/3',
|
|
|
|
|
+ # 'Upgrade-Insecure-Requests':'1',
|
|
|
|
|
+ # }
|
|
|
|
|
+ # html = get_page(start_url, options=headers)
|
|
|
|
|
+ # if html:
|
|
|
|
|
+ # find_trs = re.compile('<tr class.*?>(.*?)</tr>', re.S)
|
|
|
|
|
+ # trs = find_trs.findall(html)
|
|
|
|
|
+ # for tr in trs:
|
|
|
|
|
+ # find_ip = re.compile('<td>(\d+\.\d+\.\d+\.\d+)</td>')
|
|
|
|
|
+ # re_ip_adress = find_ip.findall(tr)
|
|
|
|
|
+ # find_port = re.compile('<td>(\d+)</td>')
|
|
|
|
|
+ # re_port = find_port.findall(tr)
|
|
|
|
|
+ # for adress,port in zip(re_ip_adress, re_port):
|
|
|
|
|
+ # adress_port = adress+':'+port
|
|
|
|
|
+ # yield adress_port.replace(' ','')
|
|
|
|
|
+
|
|
|
|
|
+ def crawl_ip3366(self):
|
|
|
|
|
+ for i in range(1, 4):
|
|
|
|
|
+ start_url = 'http://www.ip3366.net/?stype=1&page={}'.format(i)
|
|
|
|
|
+ html = get_page(start_url)
|
|
|
if html:
|
|
if html:
|
|
|
- find_trs = re.compile('<tr class.*?>(.*?)</tr>', re.S)
|
|
|
|
|
- trs = find_trs.findall(html)
|
|
|
|
|
|
|
+ find_tr = re.compile('<tr>(.*?)</tr>', re.S)
|
|
|
|
|
+ trs = find_tr.findall(html)
|
|
|
for tr in trs:
|
|
for tr in trs:
|
|
|
find_ip = re.compile('<td>(\d+\.\d+\.\d+\.\d+)</td>')
|
|
find_ip = re.compile('<td>(\d+\.\d+\.\d+\.\d+)</td>')
|
|
|
re_ip_adress = find_ip.findall(tr)
|
|
re_ip_adress = find_ip.findall(tr)
|
|
|
find_port = re.compile('<td>(\d+)</td>')
|
|
find_port = re.compile('<td>(\d+)</td>')
|
|
|
re_port = find_port.findall(tr)
|
|
re_port = find_port.findall(tr)
|
|
|
- for adress,port in zip(re_ip_adress, re_port):
|
|
|
|
|
- adress_port = adress+':'+port
|
|
|
|
|
- yield adress_port.replace(' ','')
|
|
|
|
|
|
|
+ if re_ip_adress and re_ip_adress:
|
|
|
|
|
+ for adress,port in zip(re_ip_adress, re_port):
|
|
|
|
|
+ adress_port = adress+':'+port
|
|
|
|
|
+ yield adress_port.replace(' ','')
|