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)
I have used the same code in my local Jupyter Notebook. It works. But while executing in google colab notebook it shows me the following error.
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
All the required modules were installed properly.
!pip install rake-nltk
!pip install google-search
!pip install google
!pip install urllib
!pip install beautifulsoup4
Answer is here: https://github.com/MarioVilas/googlesearch/issues/39
The problem is related to a name conflict between packages. If you just install google
and not google-search
, it will work.
!pip install google
If you already have them both installed, use:
!pip uninstall google-search
!pip uninstall google
!pip install google