Skip to content

Commit

Permalink
Update start_main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Insomnia731 authored Sep 22, 2024
1 parent a1fb25c commit 600cba9
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions start_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ async def get_ip_info():
try:
async with aiohttp.ClientSession() as session:
async with session.get("https://ipinfo.io") as response:
data = await response.json()

ip = data.get('ip')
city = data.get('city')
country = data.get('country')

print(f"IP: {ip}")
print(f"Location: {city}, {country}")
if response.status == 200:
data = await response.json()

ip = data.get('ip')
city = data.get('city')
country = data.get('country')

print(f"IP: {ip}")
print(f"Location: {city}, {country}")
else:
# Получаем текст ошибки, если не 200
error_text = await response.text()
print(f"Error: {response.status}, {error_text}")
except Exception as e:
print(f"Error: {e}")

Expand All @@ -28,5 +33,5 @@ def run_main(arg=None):

if __name__ == "__main__":
asyncio.run(get_ip_info())
time.sleep(random.randint(0, 60*2)) # 2 минуты
time.sleep(random.randint(0, 5)) # 2 минуты
run_main(["-a", "2"]) # Запускает main.py -a 2

0 comments on commit 600cba9

Please sign in to comment.