google_search ... NameError:name 'google' is not defined
Playing with some of the modules and came across this error, I seem to have a lot of them working now, BUT, I got this error on the google search?
Feb 16 19:14:44 MISP misp-modules[1794626]: File "/var/www/MISP/venv/lib/python3.8/site-packages/misp_modules/__init__.py", line 188, in run_request Feb 16 19:14:44 MISP misp-modules[1794626]: response = mhandlers[module].handler(q=jsonpayload) Feb 16 19:14:44 MISP misp-modules[1794626]: File "/var/www/MISP/venv/lib/python3.8/site-packages/misp_modules/modules/expansion/google_search.py", line 30,> Feb 16 19:14:44 MISP misp-modules[1794626]: search_results = google.search(request['url'], num_page) Feb 16 19:14:44 MISP misp-modules[1794626]: NameError: name 'google' is not defined
Thanks for the feedback.
I tried the following:
pip install git+https://github.com/abenassi/Google-Search-API
In [1]: from googleapi import google
In [2]: google.search("misp", 1)
Error occurred during loading data. Trying to use cache server https://fake-useragent.herokuapp.com/browsers/0.1.11
Traceback (most recent call last):
File "/home/adulau/.local/lib/python3.8/site-packages/fake_useragent/utils.py", line 154, in load
for item in get_browsers(verify_ssl=verify_ssl):
File "/home/adulau/.local/lib/python3.8/site-packages/fake_useragent/utils.py", line 99, in get_browsers
html = html.split('<table class="w3-table-all notranslate">')[1]
IndexError: list index out of range
It seems the module is still here but it seems the recent changes make this google search not working. We have two options:
- Finding an alternative Python library supporting search query (which seems very fragile)
- or we removed the module.