urllib.error.HTTPError: HTTP Error 429: Too Many Requests in search() of googlesearch package of Python

Viewed 662

Actually, I am running one query in the search() of GoogleSearch package of python which gives multiple links from the google search in a list format

search(query, tld='com', lang='en', num=20, start=0, stop=None, pause=2.0):

I am able to get the result also but after some time it gives an error like

for i in search(query, tld='com', lang='en', num=20, start=0, stop=None, pause=2.0):
  File "E:\crawling\venv\lib\site-packages\googlesearch\__init__.py", line 312, in search
    html = get_page(url, user_agent)
  File "E:\crawling\venv\lib\site-packages\googlesearch\__init__.py", line 176, in get_page
    response = urlopen(request)
  File "C:\Users\shubh\Anaconda3\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\shubh\Anaconda3\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "C:\Users\shubh\Anaconda3\lib\urllib\request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Users\shubh\Anaconda3\lib\urllib\request.py", line 563, in error
    result = self._call_chain(*args)
  File "C:\Users\shubh\Anaconda3\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "C:\Users\shubh\Anaconda3\lib\urllib\request.py", line 755, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "C:\Users\shubh\Anaconda3\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "C:\Users\shubh\Anaconda3\lib\urllib\request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Users\shubh\Anaconda3\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "C:\Users\shubh\Anaconda3\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "C:\Users\shubh\Anaconda3\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 429: Too Many Requests

I have also increased the pause time in the search parameter but didn't help for me.

0 Answers
Related