我试过了:
pip install beautifulsoup4
pip install beautifulsoup
pip3 install beautifulsoup4
pip3 install beautifulsoup
easy_install beautifulsoup4
easy_install beautifulsoup
这是为了这个程序:
import requests
import beautifulsoup
website = input("What website do you want to look at, please include the full web adress")
session = requests.session()
req = session.get(website)
doc = BeautifulSoup.BeautifulSoup(req.content)
print(doc.findAll('a', { "class" : "gp-share" }))
在终端(我在覆盆子pi 3上)它说我已经成功安装了它但是当我运行程序时它说没有beautiful soup
这样的东西。
非常感谢任何帮助
答案 0 :(得分:0)
美丽的汤documentation在教程中包含了使用from bs4 import BeautifulSoup
导入模块的示例。
所以,在你的情况下,替换:
带有import beautifulsoup
的 from bs4 import BeautifulSoup
和
带有doc = BeautifulSoup.BeautifulSoup(req.content)
的 doc = BeautifulSoup(req.content)
答案 1 :(得分:0)
包调用区分大小写,如果已成功安装,请将Soup构造代码字符串设置如下:
doc = beautifulsoup.BeautifulSoup(req.content)