0

What I am trying to do is make a program that goes to the website https://www.dan.me.uk/tornodes, takes what tor node IP addresses are on that website and checks to see if there is a match on my list of IP addresses.

Using Python

import requests
from bs4 import BeautifulSoup

page = requests.get('https://www.dan.me.uk/tornodes')

if "<!--__BEGIN_TOR_NODE_LIST__-->" not in page.content:
    print("LIST IS NOT READY")
else:
    list_text = page.content.split("<!--__BEGIN_TOR_NODE_LIST__-->")[1] #TAKES EVERYTHING AFTER THIS
    list_text = list_text.split("<!--__END_TOR_NODE_LIST__-->")[1] #TAKES EVERYTHING BEFORE THIS
    line_list = [line.strip() ]
    for line in list_text.split("<br>"):
        line_ip = line.strip().split("|")[0]
        #DO WHAT YOU WANT NOW
        if line_ip in my_known_ip_list:
            print("THIS IS GOOD" % line_ip)

Greatly appreciate any help given to me in advance.

enes_24
  • 11
  • 2
  • as the error implies , content probably required byte type. You can try to print out page and page.content to check – Linh Nguyen Jan 10 '20 at 02:18
  • `page.content` will always return a `bytes` type. If you want a string, you'll need `page.content.decode().split()` – C.Nivs Jan 10 '20 at 02:39
  • @C.Nivs Thank you that worked! – enes_24 Jan 10 '20 at 03:17
  • Does this answer your question? [Python - a bytes like object is required, not str](https://stackoverflow.com/questions/29643544/python-a-bytes-like-object-is-required-not-str) – C.Nivs Jan 10 '20 at 14:28

0 Answers0