Refactor init_uztracker to be asynchronous for improved performance

This commit is contained in:
Vxrtrauter
2025-09-06 00:32:25 +02:00
parent b701e75bdf
commit 87380f57af
+14 -9
View File
@@ -1,18 +1,23 @@
import requests import requests
import asyncio
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
global url_uztracker global url_uztracker
global up global up
url_uztracker = "https://uztracker.net/tracker.php?nm=" # placeholder url for now url_uztracker = "https://uztracker.net/tracker.php?nm=" # placeholder url for now
try:
response = requests.get(url_uztracker) # get da content from da url async def init_uztracker():
soup = BeautifulSoup(response.content, 'html.parser') # create bs object try:
up = True response = requests.get(url_uztracker) # get da content from da url
except requests.exceptions.RequestException as e: soup = BeautifulSoup(response.content, 'html.parser') # create bs object
print(f"\nRequest Exception on {url_uztracker}:") up = True
print(e) except requests.exceptions.RequestException as e:
print("\nIs the Site down?") print(f"\nRequest Exception on {url_uztracker}:")
up = False print(e)
print("\nIs the Site down?")
up = False
asyncio.run(init_uztracker())
def scrape_uztracker(search, debug): def scrape_uztracker(search, debug):
if up: if up: