-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproxyUpload.py
38 lines (29 loc) · 1.05 KB
/
proxyUpload.py
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
36
37
38
import json
from src.func_proxy import upload_proxy
from proxy_hunter import is_valid_proxy
from src.ProxyDB import ProxyDB
from src.func import get_relative_path
def upload_all_proxies():
db = ProxyDB(get_relative_path("src/database.sqlite"))
data_list = db.get_all_proxies()
# List comprehension to transform the list of dictionaries into a list of strings
result = [
(
f"{item['proxy']}@{item['username']}:{item['password']}"
if item["username"] and item["password"]
else item["proxy"]
)
for item in data_list
]
# Assuming 'result' is your list of strings that you want to chunk
chunk_size = 500
chunked_list = []
for i in range(0, len(result), chunk_size):
chunk = result[i : i + chunk_size]
chunked_list.append(chunk)
for chunk in chunked_list:
valid_ip_port = list(filter(is_valid_proxy, chunk))
upload_proxy(json.dumps(valid_ip_port))
# upload_proxy(json.dumps(chunk))
if __name__ == "__main__":
upload_all_proxies()