我正在尝试添加到 Bing 搜索(仅限 Web 结果)代理,以便我可以转到不同的结果页面。我知道我应该使用参数 $skip,但因为它有一个美元符号,我无法让它正确输出 URL。
我只能让它显示不正确(它需要在 & 之后使用美元符号:
https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/Web()?Query='xbox'&Page=2 _
...或者给我以下错误:
{将 Linq 表达式转换为 URI 时出错:无法添加查询选项“$Page”,因为它以保留字符“$”开头。}
这是我的代码(我的补充在底部)。任何帮助将不胜感激。谢谢!
public BingSearchContainer(Uri serviceRoot) :
base(serviceRoot) {
}
/// <summary>
/// </summary>
/// <param name="Query">Bing search query Sample Values : xbox</param>
/// <param name="Market">Market. Note: Not all Sources support all markets. Sample Values : en-US</param>
/// <param name="Adult">Adult setting is used for filtering sexually explicit content Sample Values : Moderate</param>
/// <param name="Latitude">Latitude Sample Values : 47.603450</param>
/// <param name="Longitude">Longitude Sample Values : -122.329696</param>
/// <param name="WebFileType">File extensions to return Sample Values : XLS</param>
public DataServiceQuery<WebResult> Web(String Query, String Market, String Adult, Double? Latitude, Double? Longitude, String WebFileType, String Page) {
if ((Query == null)) {
throw new System.ArgumentNullException("Query", "Query value cannot be null");
}
DataServiceQuery<WebResult> query;
query = base.CreateQuery<WebResult>("Web");
if ((Query != null)) {
query = query.AddQueryOption("Query", string.Concat("\'", System.Uri.EscapeDataString(Query), "\'"));
}
if ((Market != null)) {
query = query.AddQueryOption("Market", string.Concat("\'", System.Uri.EscapeDataString(Market), "\'"));
}
if ((Adult != null)) {
query = query.AddQueryOption("Adult", string.Concat("\'", System.Uri.EscapeDataString(Adult), "\'"));
}
if (((Latitude != null)
&& (Latitude.HasValue == true))) {
query = query.AddQueryOption("Latitude", Latitude.Value);
}
if (((Longitude != null)
&& (Longitude.HasValue == true))) {
query = query.AddQueryOption("Longitude", Longitude.Value);
}
if ((WebFileType != null)) {
query = query.AddQueryOption("WebFileType", string.Concat("\'", System.Uri.EscapeDataString(WebFileType), "\'"));
}
if ((Page != null))
{
query = query.AddQueryOption("Page", Page);
}
return query;
}
}