兵API文档V1 [英] Bing API v1 documentation

查看:189
本文介绍了兵API文档V1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道我在哪里可以找到Bings API使用以下网址的最新机制的文档:

  https://开头的API .datamarket.azure.com /冰/搜索/ V1 /网络

连自己的网站上有错误URL中的Word文档我一直在读,即 https://api.datamarket.azure。 COM /冰/ SearchWeb /网络不起作用。



我可以搜索工作,并返回结果,但无法获得总记录数,如果我使用的复合材料,我可以得到记录计数,但没有结果。



我只是在寻找如何获得计数和结果的最高最新的例子。



这是我迄今为止:

 公共类GetBingTotalRecordCount 
{
公开的IEnumerable< DisplayBingWebSearch> DisplayBingSearchResults(串Q)
{
串BingID = ConfigurationManager.AppSettings [Bing_WebSearchID];
串BingWebSearch
= ConfigurationManager.AppSettings [Bing_WebSearchURL];
变种BingContainer =新Bing.BingSearchContainer(新的URI(BingWebSearch));
BingContainer.Credentials =新的NetworkCredential(BingID,BingID);
VAR的查询= BingContainer.Composite(网络,HttpUtility.UrlEncode(Q),
EnableHighlighting,DisableQueryAlterations,EN-GB,严,
空, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
).Execute()(第)。

名单,LT; DisplayBingWebSearch>数据=新的List< DisplayBingWebSearch>();
的foreach(新DisplayBingWebSearch(){
WebTitle = results.Title
})(在query.Web VAR结果)
{
data.Add;
}
返回数据;
}
}


解决方案

您要执行自己的计数和分页。



results.Count从foreach语句会得到的返回记录的数量。



有一个最大的。每次查询50个结果,你可以指定最大结果与
$顶部= x其中x是你想要的最大结果数



例如: https://开头的用户:yourAccountKey@api.datamarket.azure.com/Bing/SearchWeb/Web查询=%27leo%20fender%27和Market =%27en美国%27安培; $ TOP = 50安培; $格式= JSON



兵使用在查询的OData参数现在这样$顶部将返回结果的数目和$跳过是偏移量。



与$顶级榜样的常见问题和$跳过可以的 http://go.microsoft.com/fwlink/?LinkID=252146



迁移指南,这是不是很有帮助的,可以在这里找到 http://go.microsoft.com/fwlink/?LinkID=248077


Does anyone know where I can find the latest documention for Bings API with the following URL:

https://api.datamarket.azure.com/Bing/Search/v1/Web

Even their own website has the wrong URL in the word docs I have been reading, i.e. https://api.datamarket.azure.com/Bing/SearchWeb/Web does not work.

I can get the search to work and return results, but cannot get the total record count, if I use composite I can get record count but no results.

I just looking for an up-to-date example of how to get both count and results.

This is what I have so far:

public class GetBingTotalRecordCount
{
    public IEnumerable<DisplayBingWebSearch> DisplayBingSearchResults(string q)
    {
        string BingID = ConfigurationManager.AppSettings["Bing_WebSearchID"];
        string BingWebSearch
            = ConfigurationManager.AppSettings["Bing_WebSearchURL"];
        var BingContainer = new Bing.BingSearchContainer(new Uri(BingWebSearch));
        BingContainer.Credentials = new NetworkCredential(BingID, BingID);
        var query = BingContainer.Composite("Web", HttpUtility.UrlEncode(q),
            "EnableHighlighting", "DisableQueryAlterations", "en-GB", "Strict",
            null, null, null, null, null, null, null, null, null
        ).Execute().First();

        List<DisplayBingWebSearch> data = new List<DisplayBingWebSearch>();
        foreach (var results in query.Web)
        {
            data.Add(new DisplayBingWebSearch() {
                 WebTitle = results.Title
            });
        }
        return data;
    }
}

解决方案

You have to perform your own counts and paging.

results.Count from your foreach statement would get the number of records returned.

There is a maximum of 50 results per query and you can specify the maximum result count with $top=x where x is your desired maximum result.

Ex: https://user:yourAccountKey@api.datamarket.azure.com/Bing/SearchWeb/Web?Query=%27leo%20fender%27&Market=%27en-US%27&$top=50&$format=JSON"

Bing uses OData parameters in the queries now so $top would be the number of results to return and $skip is the offset.

The FAQ with examples of $top and $skip can be found at http://go.microsoft.com/fwlink/?LinkID=252146

The migration guide, which is not very helpful, can be found here http://go.microsoft.com/fwlink/?LinkID=248077

这篇关于兵API文档V1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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