如何从python在google中搜索?

2024-05-23 13:43:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试制作一个脚本,对于这个脚本,我需要python在google中为我搜索,有没有办法做到这一点?就像我告诉python搜索咖啡,他会在谷歌上找到它,然后打开一个标签,在这个标签中,搜索词是咖啡? 我试过serpapi但没用还有别的方法吗? 这是我试图检查的代码,但没有用,我直接从他们的官方网站上取了下来

from serpapi.google_search_results import GoogleSearchResults
client = GoogleSearchResults({"q": "coffee", "location": "Austin,Texas", "api_key": "secretKey"})
result = client.get_dict()

Tags: 方法代码fromimport脚本clientsearchgoogle