I need to extract the google search result snippets for Arabic queries. I am using serpapi in Python. My code is as follows:
from serpapi import GoogleSearch
import os
params = {
"engine": "google",
"q": "كاس العالم",
"google_domain": "google.com.eg",
"hl":"ar",
"gl":"eg",
"num": 20,
"api_key": os.getenv("API_KEY")
}
client = GoogleSearch(params)
data = client.get_dict()
print("Organic results")
for result in data['organic_results']:
print(f"""
Title: {result['title']}
Link: {result['link']}
Position: {result['position']}
Snippet: {result['snippet']}
""")
When I write the query in the Arabic language, an error appears as follows:
KeyError: 'organic_results'
What can I do in this case?