web_search/testapi.py

22 lines
609 B
Python
Raw Permalink Normal View History

2024-12-19 03:32:54 +00:00
#from serpapi import GoogleSearch
import serpapi
params = {
"engine": "google",
"q": "小红书化妆品市场趋势2024",
# "location": "Shanghai, Shanghai, China",
# "hl": "en",
# "gl": "us",
"api_key": "036f27edccf81fa40e05cd2175ad730a9c8a44fe9f3e136acd9c67199ce7d272"
}
search = serpapi.search(params)
for key in search.keys():
print(key)
search_metadata = search['search_metadata']
print(search_metadata)
if search_metadata['status'] == 'Success':
json_record = search_metadata['json_endpoint']
# print(search.keys())
# results = search.get_dict()
# categories = results["categories"]