serpapi-python icon indicating copy to clipboard operation
serpapi-python copied to clipboard

Throwing error on `serpapi.search`

Open hilmanski opened this issue 1 year ago • 1 comments

The developer team from a high-volume customer reached out that we should throw a proper error on the serpapi.search.

I've suggested using a try-catch exception to handle errors. For example:

try:
    search = serpapi.search(q="CoffeeMilk", api_key="", engine="google", location="Austin, Texas", hl="en", gl="us")
    print(search)
    print("----------------")
except Exception as e:
    if "429" in str(e):
        print("You are being rate limited")
        print(e)
    else:
        print("An error occurred")

Intercom

sidenote: we should probably update our readme to show how to handle errors.

hilmanski avatar Nov 14 '24 04:11 hilmanski

for high volume workload, I'm in the process of upgrading to aiohttp which x10 faster, and it has a better error handling natively.

jvmvik avatar Jul 04 '25 19:07 jvmvik