获取谷歌搜索结果的数量 [英] get number of google search results

查看:116
本文介绍了获取谷歌搜索结果的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常搜索使用java检索谷歌搜索结果的数量,但没有任何效果。
我也尝试过Google Custom Search API。
我不想要结果的标题/网址,只是找到的总结果数。
有人可以指导我吗?

I searched a lot to retrieve the number of search results in google using java, but nothing worked. I have tried Google Custom Search API aswell. I don't want the title/url of results, just number of total results found. Can some one please guide me?

推荐答案

使用自定义搜索API,你就是正确的方式。

By using the Custom Search API, you're on the right way.

totalResults 键您从查询中获得的custom-search / v1 / using_rest #WorktingResultsrel =noreferrer>响应JSON 。只需抓住它的价值即可。

There's a totalResults key in the response JSON that you get from your query. Just grab it's value and you're done.

如果您希望JSON仅包含该值,请添加 fields 您的查询参数如下:

If you want your JSON to only contain that value, add the fields parameter to your query like that:

https://www.googleapis.com/customsearch/v1?key={YOUR_API_KEY}&cx={YOUR_SEARCH_ENGINE_ID}
    &q={YOUR_SEARCH_STRING}&alt=json&fields=queries(request(totalResults))

这篇关于获取谷歌搜索结果的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆