bongzilla

Untitled

Dec 24th, 2020
972
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from bs4 import BeautifulSoup
  2. import requests
  3.  
  4. user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36"
  5. headers = { "User-Agent": user_agent, "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language": "ru,en-us;q=0.7,en;q=0.3", "Accept-Charset": "windows-1251,utf-8;q=0.7,*;q=0.7", "Keep-Alive": "300", "Connection": "keep-alive" }
  6.  
  7. r = requests.get("https://ru.tld-list.com/tlds-from-a-z", headers=headers)
  8.  
  9. soup = BeautifulSoup(r.text, "html.parser")
  10. div = soup.find("div", class_="list-az")
  11. tlds = div.find_all("li")
  12.  
  13. tlds_list = []
  14.  
  15. with open("tlds.txt", "w", encoding="utf-8", newline="\n") as filehandle:
  16.     for zone in tlds:
  17.         filehandle.write(zone.text[2:])
  18.         tlds_list.append(zone.text[2:])
  19.  
  20. tlds_list = [x.replace('\n', '') for x in tlds_list]
  21.  
  22. with open("tlds_list.txt", "w", encoding="utf-8", newline="") as filehandle:
  23.     filehandle.write(str(tlds_list))
RAW Paste Data