How to get number of search result from Bing API

被刻印的时光 ゝ 提交于 2019-12-08 18:01:03

问题


I want to use bing search api to obtain search result count for given query, however, Bing API seem to not return any fields containing the search result count.

Should I specify some option to request URL? Or Bing API not return the result countt?


回答1:


You can obtain the result count, but it's not as obvious as I thought it would be. Using this URL:

https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Composite?Sources=%27web%27&Query=%27YOUR_QUERY_HERE%27&$top=1&$format=JSON

you can get a JSON String, which includes the result count in

d->results[0]->WebTotal

You need to use the Composite search for that (I specified only web in this example, but you can use web+news or any other bing source) and you have to retrieve at least one result ($top=1).

You can also use Atom instead of JSON to get an xml response.




回答2:


For those subscribed to the SearchWeb stream rather than the general Search, the URL is this:

https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/v1/Composite?Query=%27YOUR_QUERY_HERE%27&$top=1&$format=JSON

As with Wang Tang's answer, the result should include

d->results[0]->WebTotal



回答3:


You can get the results count from the result object:

results_object['searchResults']['webPages']['totalEstimatedMatches']


来源:https://stackoverflow.com/questions/13560495/how-to-get-number-of-search-result-from-bing-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!