Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python

HTML parser

I am trying to run a simple BeautifulSoup script I get the following error from the following code: (Jupyter Notebook)

from urllib.request import urlopen from bs4 import BeautifulSoup

html = urlopen('https://treehouse-projects.github.io/horse-land/index.html') soup = BeautifulSoup(html.read(), 'html-parser')

print(soup)

Error: FeatureNotFound Traceback (most recent call last) <ipython-input-13-c6a03e259650> in <module>() 3 4 html = urlopen('https://treehouse-projects.github.io/horse-land/index.html') ----> 5 soup = BeautifulSoup(html.read(), 'html-parser') 6 7 print(soup)

/home/migs/anaconda3/lib/python3.6/site-packages/bs4/init.py in init(self, markup, features, builder, parse_only, from_encoding, exclude_encodings, **kwargs) 163 "Couldn't find a tree builder with the features you " 164 "requested: %s. Do you need to install a parser library?" --> 165 % ",".join(features)) 166 builder = builder_class() 167 if not (original_features == builder.NAME or

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

1 Answer

I think you are looking for "html.parser" with a period instead of the hyphen.

html = urlopen('https://treehouse-projects.github.io/horse-land/index.html') 
soup = BeautifulSoup(html.read(), html.parser)

print(soup)