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

26
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):
retList = []
retListDomain = []
if max_len != None:
retList = []
for x in my_list:
if len(x) <= (max_len + 3):
retList.append(x)
return retList
else:
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 retListDomain
def fetch():