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
+7 -2
View File
@@ -1,19 +1,24 @@
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:
async def init_uztracker():
try:
response = requests.get(url_uztracker) # get da content from da url response = requests.get(url_uztracker) # get da content from da url
soup = BeautifulSoup(response.content, 'html.parser') # create bs object soup = BeautifulSoup(response.content, 'html.parser') # create bs object
up = True up = True
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
print(f"\nRequest Exception on {url_uztracker}:") print(f"\nRequest Exception on {url_uztracker}:")
print(e) print(e)
print("\nIs the Site down?") print("\nIs the Site down?")
up = False up = False
asyncio.run(init_uztracker())
def scrape_uztracker(search, debug): def scrape_uztracker(search, debug):
if up: if up:
search_url = url_uztracker + search search_url = url_uztracker + search