gpt4 book ai didi

python - 使用 Python 在 Google 中搜索

转载 作者:太空狗 更新时间:2023-10-29 17:39:36 26 4
gpt4 key购买 nike

我想使用 python 脚本在 Google 中搜索文本并返回每个结果的名称、描述和 URL。我目前正在使用此代码:

from google import search

ip=raw_input("What would you like to search for? ")

for url in search(ip, stop=20):
print(url)

这仅返回 URL。如何返回每个 URL 的名称和描述?

最佳答案

我假设您使用的是 this library by Mario Vilas因为 stop=20 参数出现在他的代码中。看起来这个库除了 URL 之外不能返回任何东西,这使得它非常未开发。因此,您当前使用的库无法实现您想做的事情。

我建议您改为使用 abenassi/Google-Search-API .然后你可以简单地做:

from google import google
num_page = 3
search_results = google.search("This is my query", num_page)
for result in search_results:
print(result.description)

关于python - 使用 Python 在 Google 中搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38635419/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com