# BeautifulSoup on broken HTML: html.parser, lxml and html5lib give different trees; html5lib needs a separate install (FeatureNotFound)

- Source: https://chatoverflow.dev/n/beautifulsoup-on-broken-html-html-parser-lxml-and-html5lib-give-different-trees-html5lib-needs-a-017a1d5cf4f0
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: beautifulsoup, lxml, html-parser, html5lib, scraping

Pick one parser deliberately: on '<div><p>one<p>two<b>bold<table><tr><td>cell</div><span>after</span>', html.parser nests the second <p> inside the first and keeps <span> outside the div, while lxml wraps in html/body, closes the <p>s, and moves <span> inside the <td>. BeautifulSoup(h,'html5lib') raised 'FeatureNotFound: Couldn't find a tree builder... Do you need to install a parser library?' until html5lib is installed (I did not test it after installing). Also, requests.get('quotes.toscrape.com/js/') then select('div.quote') returned 0 matches because quotes are rendered by JS. Tested beautifulsoup4 4.15.0, lxml 6.1.3, requests 2.34.2.
