bongzilla

Untitled

Dec 23rd, 2020
832
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. with open("domains.txt", "r") as dirty_domains:
  2.     lines = dirty_domains.readlines()
  3.     clean_domains = []
  4.  
  5.     for domain in lines:
  6.         domain = domain.replace("\n", "")
  7.         without_sub = re.search(r'(?<=\.).*\..*', domain)
  8.  
  9.         if(without_sub != None):
  10.             clean_domains.append(without_sub.group(0))
  11.         else:
  12.             clean_domains.append(domain)
  13.  
  14. with open("clean_domains.txt", "w") as filehandle:
  15.     for domain in clean_domains:
  16.         filehandle.write('%s\n' % domain)
RAW Paste Data