Beautiful Soup 是一个HTML/XML的解析器,主要的功能是解析和提取 HTML/XML 数据。

BeautifulSoup支持Python标准库中的HTML解析器,还支持一些第三方的解析器。通常情况下我们不会使用 Python 默认的解析器,而是使用lxml 解析器,lxml 解析器更加强大,速度更快,推荐使用 lxml 解析器。

BeautifulSoup的安装

如官网所示:

The current release is Beautiful Soup 4.9.3 (October 3, 2020). You can install Beautiful Soup 4 with pip install beautifulsoup4.

直接输入:pip install beautifulsoup4,即可安装 Beautiful Soup 4

如果是其他操作系统,则安装如下所示进行安装:

In Debian and Ubuntu, Beautiful Soup is available as the python-bs4 package (for Python 2) or the python3-bs4 package (for Python 3). In Fedora it's available as the python-beautifulsoup4 package.

lxml解析器的安装

在安装好BeautifulSoup后,我们再安装lxml解析器,也很简单:pip install lxml

更多介绍请参考:lxml官网安装教程

标签: none

[网站公告]-[2024年兼职介绍]


添加新评论