Beautiful soup and table scraper - lxml vs html parser

I am trying to extract the HTML of a table from a webpage using BeautifulSoup.

<table class="facts_label" id="facts_table">...</table>

I would like to know why the code below works with "html.parser"and prints noneif I change "html.parser"for "lxml".

#! /usr/bin/python

from bs4 import BeautifulSoup
from urllib import urlopen

webpage = urlopen('http://www.thewebpage.com')
soup=BeautifulSoup(webpage, "html.parser")
table = soup.find('table', {'class' : 'facts_label'})
print table
+4
source share
1 answer

The documentation BeautifulSouphas a special paragraph, Differences between parsers , it states that:

Beautiful Soup , . . HTML XML.

HTML-.

, , .

, , . .

+5

All Articles