Advertisement
bongzilla

Untitled

Dec 23rd, 2020
1,174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement