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
来源:https://stackoverflow.com/questions/15244280/bing-api-v1-documentation