Guest User

nyanpeers.py

a guest
May 21st, 2020
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. # Nyancoin peer list downloader, by u/nametone.
  4. # V1, May 21, 2020.
  5. # Public domain.
  6.  
  7. from bs4 import BeautifulSoup
  8. import requests
  9. import re
  10.  
  11. print("Downloading webpage...")
  12. page = requests.get("https://www.nyanchain.com/pr.nyan")
  13. print("Downloading done")
  14. soup = BeautifulSoup(page.content, 'html.parser')
  15. table = soup.select_one("table")
  16. ipv4=re.compile("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$")
  17. file=open("peers.conf","w")
  18. file.write("addnode=46.235.227.47\n") #Add jwflame's node
  19. for td in table.find_all("td"):
  20.     if ipv4.match(td.text):
  21.         file.write("addnode="+td.text+"\n")
  22. file.close()
  23. print("Writing config done")
  24. print("You can now add peers.conf's content to your nyancoin.conf configuration file.")
Advertisement
Add Comment
Please, Sign In to add comment