【发布时间】:2020-10-24 07:56:53
【问题描述】:
try:
from googlesearch import search
except ImportError:
print("No module named 'google' found")
urls = []
for j in search(str(query),tld="com",start=1, num=15, stop=15, pause=0):
print(j)
urls.append(j)
我在本地 Jupyter Notebook 中使用了相同的代码。有用。但是在 google colab notebook 中执行时,它显示了以下错误。
NameError Traceback (most recent call last)
<ipython-input-38-a97ca791b5a9> in <module>()
4 print("No module named 'google' found")
5 urls = []
----> 6 for j in google-search(str(query),tld="com",start=1, num=15, stop=15, pause=0):
7 print(j)
8 urls.append(j)
NameError: name 'search' is not defined
所有必需的模块都已正确安装。
!pip install rake-nltk
!pip install google-search
!pip install google
!pip install urllib
!pip install beautifulsoup4
【问题讨论】:
标签: python jupyter-notebook google-colaboratory google-search python-module