You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.
'''Google SearchUses Google's Custom Search API to retrieve Google Search results.input_query - The query to search for.num_results - The number of results to return.api_key - Your Google API key.cse_id - Your Google Custom Search Engine ID.output - A list of dictionaries, each dictionary is a Google Search result'''defcustom_search(query, api_key, cse_id, **kwargs):
service=build("customsearch", "v1", developerKey=api_key)
res=service.cse().list(q=query, cx=cse_id, **kwargs).execute()
returnres['items']
defgoogle_search(input_query: str):
api_key="YOUR_GOOGLE_API_KEY"cse_id='YOUR_GOOGLE_CSE_ID'num_results=10metadata_results= []
results=custom_search(input_query, num=num_results, api_key=api_key, cse_id=cse_id)
forresultinresults:
metadata_result= {
"snippet": result["snippet"],
"title": result["title"],
"link": result["link"],
}
metadata_results.append(metadata_result)
returnmetadata_results
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: