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:
parent
37e08a5bac
commit
916c567207
24
app.py
24
app.py
@ -9,19 +9,39 @@ from bs4 import BeautifulSoup
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
max_len = int(sys.argv[1])
|
max_len = int(sys.argv[1])
|
||||||
|
if max_len == 0:
|
||||||
|
max_len = None
|
||||||
except IndexError:
|
except IndexError:
|
||||||
max_len = None
|
max_len = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
top_domain = str(sys.argv[2])
|
||||||
|
except IndexError:
|
||||||
|
top_domain = None
|
||||||
|
|
||||||
def cleanlist(my_list):
|
def cleanlist(my_list):
|
||||||
if max_len != None:
|
|
||||||
retList = []
|
retList = []
|
||||||
|
retListDomain = []
|
||||||
|
if max_len != None:
|
||||||
for x in my_list:
|
for x in my_list:
|
||||||
if len(x) <= (max_len + 3):
|
if len(x) <= (max_len + 3):
|
||||||
retList.append(x)
|
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
|
return retList
|
||||||
else:
|
else:
|
||||||
return my_list
|
return retListDomain
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def fetch():
|
def fetch():
|
||||||
|
Loading…
Reference in New Issue
Block a user