0

我正在尝试使用 IWebmasterApi 中的 GetPageStats 方法获取一些页面统计信息以获取 url。它返回所有日期的统计信息。有没有办法在我们想要的日期上设置过滤器?我正在通过 Postman 发送 GET 请求,而不是使用 c# 程序。

4

2 回答 2

0

嗨不确定这是否回答了您的问题,我只是开始“挖掘”以开发一些供我使用的应用程序,通常首先我会阅读人们抱怨和失败的地方。

有一些日期过滤器...

您需要查看 C# 中的请求是什么easy ...然后进行逆向工程并在 Postman 中构建它

  var oneMonthAgo = DateTime.Now.AddMonths(-1);
  var stats = api.GetRankAndTrafficStats("http://yoursite.com/")
       .Where(s => s.Date > oneMonthAgo)
        .OrderBy(s => s.Date);

https://docs.microsoft.com/en-us/bingwebmaster/getting-started

namespace WebmasterApiExamples
{
   using System;
   using System.Linq;
   using System.ServiceModel;

   internal class Program
   {
    private static void Main(string[] args)
    {
        var api = new WebmasterApi.WebmasterApiClient();

        try
        {
            var oneMonthAgo = DateTime.Now.AddMonths(-1);
            var stats = api.GetRankAndTrafficStats("http://yoursite.com/")
                .Where(s => s.Date > oneMonthAgo)
                .OrderBy(s => s.Date);
            Console.WriteLine("Date\tImpressions\tClicks");
            foreach (var value in stats)
            {
                Console.WriteLine("{0}\t{1}\t{2}", value.Date.ToShortDateString(), value.Impressions, value.Clicks);
            }
        }
        catch (FaultException<WebmasterApi.ApiFault> fault)
        {
            Console.WriteLine("Failed to add site: {0}", fault.Message);
        }
       }
   }
}
于 2021-09-04T16:24:27.223 回答
0

经过一番挖掘,我发现在 Bing API 调用中无法进行日期过滤。每次都会发送页面统计信息的全部数据(大约 3 个月)。日期过滤器必须在客户端处理。

于 2017-06-12T19:45:03.847 回答