(not sure if this is an html5lib or bs4 issue, but any help appreciated)
NoneType error when using html5lib with beautiful soup but when using lxml no error
from bs4 import BeautifulSoup
with open('test1.html') as f:
html = f.read()
soup = BeautifulSoup(html, 'html5lib')
races = soup.select('.mb-3')
for race in races:
print(race.find('h3'))
Traceback (most recent call last):
File "test.py", line 8, in <module>
print(race.find('h3'))
File "/home/guy/anaconda3/envs/ingestion-pipeline/lib/python3.6/site-packages/bs4/element.py", line 1292, in find
l = self.find_all(name, attrs, recursive, text, 1, **kwargs)
File "/home/guy/anaconda3/envs/ingestion-pipeline/lib/python3.6/site-packages/bs4/element.py", line 1313, in find_all
return self._find_all(name, attrs, text, limit, generator, **kwargs)
File "/home/guy/anaconda3/envs/ingestion-pipeline/lib/python3.6/site-packages/bs4/element.py", line 552, in _find_all
i = next(generator)
File "/home/guy/anaconda3/envs/ingestion-pipeline/lib/python3.6/site-packages/bs4/element.py", line 1327, in descendants
stopNode = self._last_descendant().next_element
AttributeError: 'NoneType' object has no attribute 'next_element'
but using lxml instead of html5lib
from bs4 import BeautifulSoup
with open('test1.html') as f:
html = f.read()
soup = BeautifulSoup(html, 'lxml')
races = soup.select('.mb-3')
for race in races:
print(race.find('h3'))
(not sure if this is an
html5lib
orbs4
issue, but any help appreciated)NoneType
error when usinghtml5lib
with beautiful soup but when usinglxml
no errorbut using
lxml
instead ofhtml5lib
here is
test1.html