diff --git a/app.py b/app.py index 1d39f36..149b488 100755 --- a/app.py +++ b/app.py @@ -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():