beautifulsoup 和 bs4 有什么区别

What is the difference beautifulsoup and bs4

我是 python 的新手,我尝试解析一些 XML 文件以添加一些新标签并存储新的 XML 文件。

python-beautifulsoup 接缝是合适的包装。在网上搜索教程,如何向 BeautifulSoup 解析的 XML 添加新标签,我发现使用了包 python-bs4

查看包说明,两个包的标题相同:

python-bs4 - error-tolerant HTML parser for Python
python-beautifulsoup - error-tolerant HTML parser for Python

所以我的问题是:有什么区别?

当我转到beautifulsoup 4.0 documentation时,第一页有这样的信息:

(The BeautifulSoup package is probably not what you want. That’s the previous major release, Beautiful Soup 3. Lots of software uses BS3, so it’s still available, but if you’re writing new code you should install beautifulsoup4.)

那些像我一样,在多年后阅读的人,请注意。以上是指使用系统包管理器安装,例如 apt-get,您可以从中安装 python-bs4 或 python3-bs4。

如果使用 pip 安装,请使用 pip install beautifulsoup4,目前为 V4.7.1。

自 2016 年 3 月以来 bs4 package on PyPI 描述是

This is a dummy package managed by the developer of Beautiful Soup to prevent name squatting. The official name of PyPI’s Beautiful Soup Python package is beautifulsoup4. This package ensures that if you type pip install bs4 by mistake you will end up with Beautiful Soup.