lagranges / people_also_ask

Python wrapper for google people-alos-ask
MIT License
100 stars 44 forks source link

Getting GoogleSearchRequestFailedError if I run get_answer() for a list of questions #7

Closed gabriead closed 2 years ago

gabriead commented 2 years ago

HI @lagranges,

first of all great tool! I am iterating over a list of approx. 1000 questions and calling the get_answer() function. After approx. 100 questions I am getting a ´´´GoogleSearchRequestFailedError ´´´ from google.py. I have included a sleep before calling get_answer, but it still occurs. Does this have to do with Googles limit on API calls?

 for ques in questions:
      sleep = randint(1,30)
      answer = people_also_ask.get_answer(ques)
error
lagranges commented 2 years ago

Hi @gabriead,

It seems to work for me.

Did you get the same error by re-running the code ? If so, Does it work if with time.sleep(5) ?

Actually, if you run only the above code, there is at most 60 requests sent per minute which is far from google request limit (10 request per second if i am not wrong).

Best regards,

Tuan.

dc93 commented 2 years ago

Hello.

Unfortunately happened same with me..

example code is this

! /usr/bin/env python3

import os import sys import time import logging import requests from people_also_ask import get_related_questions, generate_related_questions

get_related_questions("github",10)

for question in generate_related_questions("how to file divorce in California"): print(question)

error is this

2022-05-01 22_05_15-_root_people_also_ask_paa py - root@95 216 117 116 - Editor - WinSCP

python version (i'm on centos 7)

Python 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux Type "help", "copyright", "credits" or "license" for more information.

extension module 'readline' loaded from '/usr/lib64/python3.6/lib-dynload/readline.cpython-36m-x86_64-linux-gnu.so'

extension module 'readline' executed from '/usr/lib64/python3.6/lib-dynload/readline.cpython-36m-x86_64-linux-gnu.so'

import 'readline' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fe3cc7b26d8> import 'atexit' # <class '_frozen_importlib.BuiltinImporter'>

/usr/lib64/python3.6/pycache/rlcompleter.cpython-36.pyc matches /usr/lib64/python3.6/rlcompleter.py

code object from '/usr/lib64/python3.6/pycache/rlcompleter.cpython-36.pyc'

import 'rlcompleter' # <_frozen_importlib_external.SourceFileLoader object at 0x7fe3cc7b27b8>

Thanks so much!

rahat10120141 commented 2 years ago

i am having same issue

lagranges commented 2 years ago

Hello,

Thank you for raising this issue. The query got banned from google. I'll keep you posted on the fix. Same issue here #8 , so i closed this issue.