-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetFreeProxy.py
More file actions
35 lines (26 loc) · 844 Bytes
/
getFreeProxy.py
File metadata and controls
35 lines (26 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'''
free proxy website:
https://free-proxy-list.net/
'''
import time
import requests
from bs4 import BeautifulSoup
UserAgent = "Chrome/77.0.3865.90"
headers = {'User-Agent': UserAgent}
response = requests.session()
url = "https://free-proxy-list.net/"
url_source = response.get(url, headers=headers).text
url_DOM = BeautifulSoup(url_source, 'html.parser')
#print(url_source)
proxy_txt = ''
for i in url_DOM.find('tbody').find_all('tr'):
proxyInfo = i.find_all('td')
proxy_ip = proxyInfo[0].getText()
proxy_port = proxyInfo[1].getText()
proxy_supportHttps = proxyInfo[6].getText()
proxy_data = proxy_ip + ":" + proxy_port
#print(proxy_data)
proxy_txt = proxy_txt + proxy_data + "\n"
print(proxy_txt)
with open ("./freeProxy.txt","w+") as f:
f.write(proxy_txt)