-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecker.py
36 lines (28 loc) · 1.11 KB
/
checker.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
import httpx
import asyncio
import logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
PROXY_SERVER = 'http://user:[email protected]:8181' # Адрес нашего прокси-сервера
TARGET_URL = 'https://ifconfig.me/ip'
REQUESTS_PER_SECOND = 1
async def fetch_ip():
try:
proxies = {"http://": PROXY_SERVER, "https://": PROXY_SERVER}
async with httpx.AsyncClient(proxies=proxies) as client:
response = await client.get(TARGET_URL)
if response.status_code == 200:
ip = response.text.strip()
logging.info(f"Current IP: {ip}")
else:
logging.warning(f"Failed to fetch IP: {response.status_code}")
except httpx.RequestError as e:
logging.error(f"Request error: {e}")
except Exception as e:
logging.error(f"Error fetching IP: {e}")
async def main():
while True:
tasks = [fetch_ip() for _ in range(REQUESTS_PER_SECOND)]
await asyncio.gather(*tasks)
await asyncio.sleep(1)
if __name__ == "__main__":
asyncio.run(main())