靓汤馅饼

2024-04-27 04:11:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我试过:

  • 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" }))

在终端(我在raspberry Pi3上),它说我已经成功地安装了它,但是当我运行程序时,它说没有beautiful soup。在

如有任何帮助,我们将不胜感激


Tags: installpip项目importinputdocsessioneasy
2条回答

包调用区分大小写,如果已成功安装,请将Soup构造代码字符串放在如下位置:

doc = beautifulsoup.BeautifulSoup(req.content)

漂亮的汤documentation在教程中包含了一个使用from bs4 import BeautifulSoup导入模块的示例。在

因此,在您的情况下,替换:

import beautifulsoupfrom bs4 import BeautifulSoup

以及

doc = BeautifulSoup.BeautifulSoup(req.content)带{}

相关问题 更多 >