serpapi / google-search-results-python

Google Search Results via SERP API pip Python Package
MIT License
600 stars 97 forks source link

[Readme] Error in Batch Asynchronous Searches Example #71

Open schaferyan opened 2 months ago

schaferyan commented 2 months ago

Currently, the example provided in the README for Batch Asynchronous Searches fails with KeyError: 'search_metadata'.

The reason for this is that the search object used to perform the initial searches is used again to call the Search Archive API without removing the previous parameters. This causes the Search Archive API to return a {'error': 'You are using queryqparameter on our Search Archive API. To make a new search, use: https://serpapi.com/search.json?q=coffee'} response.

This is fixed by replacing search_archived = search.get_search_archive(search_id) with search_archived = GoogleSearch({}).get_search_archive(search_id).

We can correct this in the README to help prevent confusion for users attempting to follow the example.