summaryrefslogtreecommitdiff
path: root/other_scripts/desec.py
blob: ac7b9c4d1ba96bfa5c31220514dc6d355ac27ddf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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