【问题标题】:ImportError: cannot import name 'search' from 'googlesearch' [closed]ImportError:无法从“googlesearch”导入名称“search”[关闭]
【发布时间】:2021-06-18 22:40:42
【问题描述】:

我安装了所有必需的库。 已经安装了 google、google-search、google-cloud、googlesearch-python、beautifulsoup4。但毕竟我得到了这个错误:

**Traceback (most recent call last):
  File "/usr/local/bin/sigit", line 9, in <module>
    from googlesearch import search
ImportError: cannot import name 'search' from 'googlesearch' (/usr/local/lib/python3.9/dist-packages/googlesearch/__init__.py)**

请帮我解决这个问题。

【问题讨论】:

标签: python pip google-search kali-linux


【解决方案1】:

这真的很奇怪,因为 pypi.org 推荐的导入根本不起作用。我挖掘了这个库的文件,这个解决方案对我有用:

from googlesearch.googlesearch import GoogleSearch

search_engine = GoogleSearch()
response_object = search_engine.search('test')
print(response_object)

pypi.org 上,最新版本并不旧,因此不应弃用。

编辑

这是我想出的确切示例:https://pypi.org/project/google-search/。 但是没有给出任何结果。这又是一件奇怪的事。我建议你不要管这个库,找一些好的、免费的谷歌搜索引擎 api。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-06
    • 1970-01-01
    • 1970-01-01
    • 2022-01-22
    相关资源
    最近更新 更多