python - 我怎样才能从 bs4 导入 BeautifulSoup?

标签 python beautifulsoup

这段代码:

from bs4 import BeautifulSoup  

不起作用,并给出此错误:

raise AttributeError, "'%s' object has no attribute '%s'" % (self.__class__.__name__,attr)    
                    ^
SyntaxError: invalid syntax    

我该怎么办?

最佳答案

你应该使用 pip 来安装,所以你可以简单地做

pip install beautifulsoup4

这将安装最新的 BS4,截至 2013 年 8 月 15 日为 4.3.1。它支持 Python 3。

关于python - 我怎样才能从 bs4 导入 BeautifulSoup?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18831380/

相关文章:

python - 如何获取倒数第二个元素?

靠近相机时,Python 光线追踪会扭曲物体形状

python - 使用 BeautifulSoup Python 获取特定文本,例如 "Something new"

python - 美汤 4 : AttributeError: NoneType has no attribute find_next

python - 网页抓取 - 使用 BeautifulSoup 和 Python 从类(class)中获取文本?

python - 如何使用 BeautifulSoup 在两个不同的标签之间获取值(value)?

python - Django 1.11.1 项目上没有生成 SessionID

python - 在Python中重置或重新读取stdin?

python - 如何使用 BeautifulSoup (Python) 从 HTML 标签中提取文本?

python - 占位符返回 gen_array_ops._placeholder(dtype=dtype, shape=shape, name=name)