-
Notifications
You must be signed in to change notification settings - Fork 522
Expand file tree
/
Copy pathget_proxy.py
More file actions
22 lines (21 loc) · 750 Bytes
/
Copy pathget_proxy.py
File metadata and controls
22 lines (21 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from urllib import request
from bs4 import BeautifulSoup
fp = open('host.txt', 'w')
for i in range(1,3):
url='http://www.xicidaili.com/wn/' + str(i)
opener=request.build_opener()
opener.addheaders = [('User-Agent',
'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36')]
request.install_opener(opener)
response = request.urlopen(url)
soup = BeautifulSoup(response.read(),'html.parser')
list = soup.find_all(class_='odd')
for elem in list:
data = elem.find_all('td')
ip=data[1].string
port=data[2].string
fp.write(ip)
fp.write('\t')
fp.write(port)
fp.write('\n')
fp.close()