英文文档:https://www.crummy.com/software/BeautifulSoup/bs4/doc/
中文文档:https://www.crummy.com/software/BeautifulSoup/bs4/doc/index.zh.html
PyPI:https://pypi.org/search/?q=beautifulsoup4
pip安装:
pip install beautifulsoup4
wheel安装(在pypi下载wheel文件,然后pip安装wheel文件即可):
验证安装:
from bs4 import BeautifulSoup
soup = BeautifulSoup('Hello soup
','lxml')
print(soup.p.string)
解析器
BeautifulSoup在解析时实际上依赖解析器,它除了支持python标准库中的HTML解析器之外,还支持一些第三方解析器(比如lxml)。如下表所示: