Last active
March 24, 2025 09:40
-
-
Save sevbo2003/71502482a2904cd526c1b73964e7602b to your computer and use it in GitHub Desktop.
Domain checker(only for uzbekistan)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
import time | |
def create_session(): | |
"""Create a new session and retrieve CSRF token.""" | |
session = requests.Session() | |
login_url = "https://clients.ahost.uz/login.php" | |
login_page = session.get(login_url) | |
soup = BeautifulSoup(login_page.text, "html.parser") | |
csrf_token_input = soup.find("input", {"name": "token"}) | |
if csrf_token_input: | |
return session, csrf_token_input["value"] | |
else: | |
print("❌ CSRF Token not found. Check the login page structure.") | |
exit() | |
# Initialize session and CSRF token | |
session, csrf_token = create_session() | |
check_url = "https://clients.ahost.uz/index.php?rp=/domain/check" | |
for i in range(1, 1001): # Loop from 1 to 1000 | |
domain_name = f"{i}.uz" | |
domain_data = { | |
"domain": domain_name, | |
"type": "domain", | |
"a": "checkDomain", | |
"token": csrf_token | |
} | |
try: | |
response = session.post(check_url, data=domain_data) | |
response_json = response.json() # Parse JSON response | |
# Debugging: Print unexpected responses | |
if "result" not in response_json or not isinstance(response_json["result"], list): | |
print(f"⚠️ Unexpected response for {domain_name}: {response_json}") | |
continue # Skip this iteration | |
if not response_json["result"]: | |
print(f"⚠️ No data found for {domain_name}. Skipping...") | |
continue # Skip if result is empty | |
domain_info = response_json["result"][0] # Extract first domain result | |
is_available = domain_info.get("isAvailable", False) | |
price = domain_info.get("shortestPeriod", {}).get("register", "N/A") | |
print(f"🔍 Domain: {domain_name} » {'✅ Available' if is_available else '❌ Taken'} | Price: {price}") | |
except requests.exceptions.JSONDecodeError: | |
print(f"❌ Failed to parse JSON for {domain_name}. Full response:") | |
print(response.text) | |
except requests.RequestException as e: | |
print(f"❌ Request error for {domain_name}: {e}") | |
session, csrf_token = create_session() # Recreate session on network issues | |
time.sleep(1) # Delay to prevent rate-limiting |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It checks domain from 1 to 1000