Add possibilty to limit to .no or .se. Use: ./app.py <domain_length> <no or se> E.g.: ./app.py 4 no or ./app.py 0 se

This commit is contained in:
Rune Olsen 2024-09-09 15:41:20 +02:00
parent 37e08a5bac
commit 916c567207

24
app.py
View File

@ -9,19 +9,39 @@ from bs4 import BeautifulSoup
try:
max_len = int(sys.argv[1])
if max_len == 0:
max_len = None
except IndexError:
max_len = None
try:
top_domain = str(sys.argv[2])
except IndexError:
top_domain = None
def cleanlist(my_list):
if max_len != None:
retList = []
retListDomain = []
if max_len != None:
for x in my_list:
if len(x) <= (max_len + 3):
retList.append(x)
if top_domain != None and len(retList) != 0:
for x in retList:
if x[-2:] == top_domain:
retListDomain.append(x)
elif top_domain != None and len(retList) == 0:
for x in my_list:
if x[-2:] == top_domain:
retListDomain.append(x)
if len(retList) == 0 and len(retListDomain) == 0:
return my_list
elif top_domain == None:
return retList
else:
return my_list
return retListDomain
def fetch():