Harrison/serp api imp (#444)

improve serp api

Co-authored-by: Bruno Bornsztein <bruno.bornsztein@gmail.com>
harrison/combine-docs-parse
Harrison Chase 1 year ago committed by GitHub
parent ffe35c396c
commit c994ce6b7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -92,6 +92,16 @@ class SerpAPIWrapper(BaseModel):
toret = res["answer_box"]["snippet_highlighted_words"][0]
elif "snippet" in res["organic_results"][0].keys():
toret = res["organic_results"][0]["snippet"]
elif (
"sports_results" in res.keys()
and "game_spotlight" in res["sports_results"].keys()
):
toret = res["sports_results"]["game_spotlight"]
elif (
"knowledge_graph" in res.keys()
and "description" in res["knowledge_graph"].keys()
):
toret = res["knowledge_graph"]["description"]
else:
toret = "No good search result found"
return toret

Loading…
Cancel
Save