import requests

url = "https://desec.io/api/v1/domains/"
response = requests.get(url, headers={"Authorization": "Token <your_token_here>"})
data = response.json()

domains = [item['name'] for item in data]

print("| Counter | Name |")
print("| ------- | ---- |")
for i, name in enumerate(domains):
    print(f"| {i+1} | {name} |")

query = input("Enter a counter or a name: ")
seldomain = None

try:
    query = int(query)
    if query < 1 or query > len(domains):
        raise ValueError
    seldomain = domains[query-1]
except ValueError:
    if query not in domains:
        print("The name is not present in the table.")
        continue
    seldomain = query