-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.py
35 lines (27 loc) · 918 Bytes
/
start.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
import httpx
import time
proxy_file = "proxy.txt"
def get_next_proxy(proxy_file: str) -> str:
with open(proxy_file, "r") as f:
proxies = f.readlines()
proxy = proxies.pop(0).strip()
proxies.append(proxy)
with open(proxy_file, "w") as f:
f.writelines(proxies)
return proxy
proxy = get_next_proxy(proxy_file)
proxy_address, proxy_port, proxy_username, proxy_password = proxy.split(":")
proxy = f"http://{proxy_username}:{proxy_password}@{proxy_address}:{proxy_port}"
proxies = {
"http://": proxy,
"https://": proxy
}
client = httpx.Client(proxies=proxies)
response = client.get("https://api.ipify.org/?format=json")
if response.status_code == 200:
data = response.json()
ip_address = data["ip"]
print("IP Adresi:", ip_address)
else:
print("İstek başarısız! Hata kodu:", response.status_code)
client.close()