【发布时间】:2014-11-01 02:12:15
【问题描述】:
我正在尝试使用 BeautifulSoup 从网页中提取表格的 HTML 代码。
<table class="facts_label" id="facts_table">...</table>
我想知道为什么下面的代码可以与"html.parser" 一起使用,如果我将"html.parser" 更改为"lxml",则会打印回none。
#! /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
【问题讨论】:
标签: python web-scraping html-parsing beautifulsoup lxml