Trying to write a parser (for the first time in my life). Here I try to do a search on the "Championship" It gives an error
'NoneType' object has no attribute 'prettify'
It seems that something is wrong
import urllib.request from bs4 import BeautifulSoup def get_html(url): response = urllib.request.urlopen(url) return response.read() def parse(html): soup = BeautifulSoup(html) table = soup.find('div',class_='livetable zbyqj js-livetable') print(table.prettify()) print(parse(get_html('https://www.championat.com/')))
BeautifulSoup(html)add the argumentlxmlBeautifulSoup(html, "lxml")- Twissreturn html_strwithreturn html_str) and explicitly state what specific element you want to find ¶ It’s better to use theselect()method to avoid thinking about the number of classes. crummy.com/software/BeautifulSoup/bs4/doc/… - jfs