Skip to content

Commit db089be

Browse files
committed
Refactor find_domain_id function to simplify domain ID extraction and remove unused variables
1 parent d6185bd commit db089be

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

domain92/__main__.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,7 @@ def getdomains(arg):
187187

188188

189189
def find_domain_id(domain_name):
190-
found = False
191190
page = 1
192-
names = []
193191
ids = []
194192
html = req.get(
195193
"https://freedns.afraid.org/domain/registry/?page="
@@ -213,17 +211,13 @@ def find_domain_id(domain_name):
213211
"sec-ch-ua-platform": "Linux",
214212
},
215213
).text
216-
pattern = r"<a href=/subdomain/edit\.php\?edit_domain_id=\d+>([\w.-]+)</a>.*?<td>public</td>"
217-
names.extend(re.findall(pattern, html))
218214
pattern = r"<a href=\/subdomain\/edit\.php\?edit_domain_id=([0-9]+)><font color=red>(?:.+\..+)<\/font><\/a>"
219215
matches = re.findall(pattern, html)
220-
ids.extend([match[0] for match in matches])
221-
if len(ids) > 0:
222-
found = True
223-
checkprint(f"Found domain ID: {ids[0]}")
216+
if len(matches) > 0:
217+
checkprint(f"Found domain ID: {matches[0]}")
224218
else:
225219
raise Exception("Domain ID not found")
226-
return ids[0]
220+
return matches[0]
227221

228222

229223

0 commit comments

Comments
 (0)