-
Notifications
You must be signed in to change notification settings - Fork 3
/
downloader
29 lines (22 loc) · 972 Bytes
/
downloader
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
import requests, json, os, re
from tqdm import tqdm
from urllib.parse import urlparse
os.makedirs('proxies', exist_ok=True)
def download(type, lists):
proxies = set()
for url in tqdm(lists, desc=f"Downloading {type}", unit="file"):
response = requests.get(url)
if response.status_code == 200:
proxy = response.text.strip().split('\n')
valid = [line.strip() for line in proxy if all(
char not in line for char in ['/', '<', '>', '=']
) and line.strip() != '' and len(line) >= 8 and len(line) <= 24 and not re.search('[a-zA-Z]', line)]
proxies.update(valid)
output = os.path.join('proxies', f"{type}.txt")
with open(output, 'w', encoding='utf-8') as f:
f.write('\n'.join(proxies))
return output
with open('lists.json', 'r') as json_file:
proxylist = json.load(json_file)
for type, lists in proxylist['proxies'].items():
output = download(type, lists)