Example #1
0
        static void Main(string[] args)
        {
            Console.Title = "WeiboLike";
            timer         = new Timer(new TimerCallback(TimerUp), null, Timeout.Infinite, 1000);

            while (true)
            {
                //Console.WriteLine("请输入用户ID:");
                //string uid = Console.ReadLine();
                //if (string.IsNullOrEmpty(uid))
                //{
                //    continue;
                //}
                //Console.WriteLine("请输入微博ID:");
                //string weiboid = Console.ReadLine();
                //if (string.IsNullOrEmpty(weiboid))
                //{
                //    continue;
                //}
                Console.WriteLine("请粘贴微博URL链接:");
                string[] uidweiboid = WeiboHelper.GetUidWeiboID(Console.ReadLine());
                if (string.IsNullOrEmpty(uidweiboid[0]) || string.IsNullOrEmpty(uidweiboid[1]))
                {
                    Console.WriteLine("从链接获取uid/微博id失败,请重试。");
                    continue;
                }

                Console.WriteLine("正在获取Mid...");
                mid = WeiboHelper.GetMid(uidweiboid[0], uidweiboid[1]);
                if (string.IsNullOrEmpty(mid))
                {
                    Console.WriteLine("没有获取到Mid,请重试。");

                    continue;
                }
                Console.WriteLine("已获取到MID:" + mid);
                Console.WriteLine("请输入微博数据保存文件名:");
                savename = Console.ReadLine() + ".json";
                Console.WriteLine("开始抓取本条微博的点赞用户数据...");
                timer.Change(0, 1000);
                //第一步获取点赞基本数据
                ulist     = WeiboHelper.GetPageLikeLinks(mid, 1);
                totalpage = ulist.TotalPage;

                GetWeiboUser getWeiboUser = new GetWeiboUser(ulist.UserLinks, 60);
                getWeiboUser.GetCompleted += GetCompleted;
                getWeiboUser.Get();

                Console.ReadKey();
            }
        }