コード例 #1
0
        public MonitorTimer(WeiboLogin wbLogin, string uid)
        {
            this.wbLogin = wbLogin;
            this.uid     = uid;
            string html = wbLogin.Get("https://weibo.com/" + uid + "?is_all=1");

            oldPage = new WeiboPage(html);
        }
コード例 #2
0
ファイル: WeiboFeed.cs プロジェクト: jiafenggit/WeiboMonitor
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="id"></param>
        /// <param name="time"></param>
        /// <param name="content"></param>
        public WeiboFeed(WeiboPage fatherPage, string id, string username, string time, string content, bool isLike)
        {
            WBPage   = fatherPage;
            ID       = id;
            Username = username;
            Content  = content;
            IsLike   = isLike;

            Time = DateTime.Parse(time);
        }
コード例 #3
0
        private void mTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            lock (this)
            {
                if (restTime[DateTime.Now.Hour])
                {
                    AppendText(rtbOutput, "现在处于休息时间" + Environment.NewLine);
                    return;
                }

                MonitorTimer     t             = (MonitorTimer)sender;
                string           html          = wbLogin.Get("https://weibo.com/" + t.Uid + "?is_all=1");
                WeiboPage        newPage       = new WeiboPage(html);
                List <WeiboFeed> newWbFeedList = newPage.Compare(t.OldPage.WbFeedList);
                if (newWbFeedList != null)
                {
                    for (int i = 0; i < newWbFeedList.Count; i++)
                    {
                        //newWbFeedList[i].Like(wbLogin, true);
                        //MessageBox.Show(wbLogin.Uid);
                        newWbFeedList[i].Comment(wbLogin, txtContent.Text, wbLogin.Uid, forward.Checked);
                    }
                    t.OldPage = newPage;

                    // 输出相关信息
                    if (newWbFeedList.Count > 0)
                    {
                        AppendText(rtbOutput, DateTime.Now.ToString("HH:mm:ss") + " 发现新微博:" + Environment.NewLine);
                        for (int i = 0; i < newWbFeedList.Count; i++)
                        {
                            AppendText(rtbOutput, "[" + i + "] [" + newWbFeedList[i].Content.Trim() + "]" + Environment.NewLine);
                        }
                    }
                    else
                    {
                        AppendText(rtbOutput, DateTime.Now.ToString("HH:mm:ss") + " 当前页微博个数:" + newPage.WbFeedList.Count + Environment.NewLine);
                    }
                }
                else
                {
                    AppendText(rtbOutput, "本次微博页面获取失败" + Environment.NewLine);
                }
            }
        }