1

I got this error when running my python code:

bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library?

So I searched online and read this

I checked my packages installed, both html5lib and six seem to be the latest version.

beautifulsoup4 (4.6.0)
html5lib (1.0.1)
pip (9.0.1)
setuptools (28.8.0)
six (1.11.0)
webencodings (0.5.1)

I wonder what is the problem here?

*The context:

import urllib.request
from bs4 import BeautifulSoup

url0 = 'http://py4e-data.dr-chuck.net/known_by_Cruz.html'

url = url0
name = list()
for i in range(0,7):
    html = urllib.request.urlopen(url).read()
    soup = BeautifulSoup(html,"html5lib")
....

When I ran the exact same code in jupyter notebook it ran without problem.

raffa
  • 125
  • 1
  • 11

1 Answers1

2

You try to replace "htmllib" with "html.parser"

For example:

soup = BeautifulSoup(html,"html5lib") **->** soup = BeautifulSoup(data, "html.parser")
iBug
  • 32,728
  • 7
  • 79
  • 117
Binh ED
  • 11
  • 1
  • Thank you, it worked, but could you explain why? In the beginning i just used `soup = BeautifulSoup(html)` and then, I wrote it like that becasue there showed up a warning message telling me to add "html5lib" to it... – raffa Jan 06 '18 at 19:05