Nv7-GitHub / googlesearch

A Python library for scraping the Google search engine.
https://pypi.org/project/googlesearch-python/
MIT License
480 stars 117 forks source link

Import Error #68

Closed SafalAdhikari7 closed 2 months ago

SafalAdhikari7 commented 11 months ago

The error says: cannot import name 'search' from 'googlesearch'

So, I need help regarding this error.

challenge3697 commented 10 months ago

Hi, you need to install the module first, open your terminal and run this python3 -m pip install googlesearch-python

jeremystevens commented 10 months ago

check out my fork i fixed the problem I added a section at the bottom of the README.md that has a screenshot of the results and also included a usage example . View fork here

  1. I installed in a virtual environment
  2. I located the file here venv/lib/python3.10/site-packages/googlesearch
  3. I backed up the googlesearch.py and then copied the new modified version of googlesearch.py to that directory

here is the example usage

from googlesearch import Search
query = "programming"
language = "en"  # Language (default is "en")
number_of_results = 20  # Number of results (default is 10)
retry_count = 3  # Retry count (default is 3)
parser = "html.parser"  # HTML parser (default is "html.parser")

search = Search(query, language=language, number_of_results=number_of_results, retry_count=retry_count, parser=parser)

# Perform the search using the specified parameters
search.search()

# Access the search results
results = search.results
print(results)