コード例 #1
0
        //粉丝事件
        private void FollowFansEvent(object sender, bool isFollow)
        {
            if (isFollow)
            {
                int countFans = ((UserLable)sender).AutoFollowCount;
                //关注count个用户
                string oid = SqliteTool.GetRandomOid(((UserLable)sender).DisplayName);
                if (!oid.Equals(""))
                {
                    int count = WeiboOperateTool.FollowUsersFans(oid, countFans, ((UserLable)sender).Cookies);
                    if (count < countFans)
                    {
                        count += WeiboOperateTool.FollowUsersFans(SqliteTool.GetRandomOid(((UserLable)sender).DisplayName), countFans - count, ((UserLable)sender).Cookies);
                    }

                    UserLog.WriteNormalLog(((UserLable)sender).DisplayName, String.Format("关注{0}人", count), String.Format("被抓取oid:{0}", oid));
                }
            }
            else
            {
                int count = ((UserLable)sender).AutoUnFollowCount;
                WeiboOperateTool.UnFollowMyFans(count, ((UserLable)sender).Cookies, ((UserLable)sender).UserId);
                UserLog.WriteNormalLog(((UserLable)sender).DisplayName, String.Format("取消关注{0}人", count));
            }
        }
コード例 #2
0
        private void buttonStartGetWeibo_Click(object sender, EventArgs e)
        {
            //判断有效条件
            if ((!this.checkBoxGetImageWeibo.Checked && !this.checkBoxGetVideoWeibo.Checked) ||
                this.textBoxGetWeibo.Text.Equals("") ||
                this.checkedListBox1.CheckedItems.Count == 0)
            {
                return;
            }

            //关闭操作功能
            this.checkBoxGetImageWeibo.Enabled = false;
            this.checkBoxGetVideoWeibo.Enabled = false;
            this.textBoxGetWeibo.Enabled       = false;
            this.buttonStartGetWeibo.Enabled   = false;

            //获取图文微博
            if (this.checkBoxGetImageWeibo.Checked)
            {
                //获取微博
                CookieContainer   cookies     = (this.panel1.Controls[0] as UserLable).Cookies;
                List <ImageWeibo> imageWeibos = WeiboOperateTool.GetImageWeibos(this.textBoxGetWeibo.Text, out string oid, cookies);

                for (int i = 0; i < this.checkedListBox1.Items.Count; i++)
                {
                    if (this.checkedListBox1.GetItemChecked(i))
                    {
                        string nickName   = this.checkedListBox1.Items[i].ToString();
                        int    StartCount = SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.ImageWeibo, nickName);

                        SqliteTool.InsertImageWebos(imageWeibos, nickName);

                        int endCount = SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.ImageWeibo, nickName);

                        UserLog.WriteNormalLog(nickName, String.Format("爬取图文微博{0}条", endCount - StartCount), String.Format("被爬取用户ID:{0}", this.textBoxGetWeibo.Text));

                        string requestStr = DateTime.Now.ToString("yyyy-MM-dd HH:MM:ss") + "\n[" + nickName + "]获取结束:此次共取得图文微博" + (endCount - StartCount).ToString() + "条";
                        this.richTextBox1.Text = this.richTextBox1.Text + requestStr + "\n";

                        //uid可以正常获取数据时说明有效,存入数据库
                        if (endCount - StartCount > 0)
                        {
                            SqliteTool.InsertUidAndOid(this.textBoxGetWeibo.Text, oid, nickName);
                        }
                    }
                }
            }

            //获取视频微博
            if (this.checkBoxGetImageWeibo.Checked)
            {
            }

            //重启界面操作
            this.checkBoxGetImageWeibo.Enabled = true;
            this.checkBoxGetVideoWeibo.Enabled = true;
            this.textBoxGetWeibo.Enabled       = true;
            this.buttonStartGetWeibo.Enabled   = true;
        }
コード例 #3
0
        //更新数据库事件
        private void UpdateSQLiteEvent(object sender)
        {
            List <string> uids = SqliteTool.Get10Uid(((UserLable)sender).DisplayName);

            foreach (string uid in uids)
            {
                int StartCount = SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.ImageWeibo, ((UserLable)sender).DisplayName);
                List <ImageWeibo> imageWeibos = WeiboOperateTool.GetImageWeibos(uid, out string oid, ((UserLable)sender).Cookies);
                SqliteTool.InsertImageWebos(imageWeibos, ((UserLable)sender).DisplayName);
                int endCount = SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.ImageWeibo, ((UserLable)sender).DisplayName);
                UserLog.WriteNormalLog(((UserLable)sender).DisplayName, String.Format("后台爬取图文微博{0}条", endCount - StartCount), String.Format("被爬取用户ID:{0}", uid));
            }
            //更新微博显示
            ((UserLable)sender).ImageWeiboCount = SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.ImageWeibo, ((UserLable)sender).DisplayName).ToString();
            ((UserLable)sender).VideoWeiboCount = SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.VideoWeibo, ((UserLable)sender).DisplayName).ToString();
        }
コード例 #4
0
        //发布一条图文微博
        private void PublishAnImageWeibo(UserLable userLable)
        {
            if (SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.ImageWeibo, userLable.DisplayName) != 0)
            {
                ImageWeibo weibo = SqliteTool.GetARandomImageWeiboIsNotPublished(SqliteTool.WeiboType.ImageWeibo, userLable.DisplayName);

                if (weibo.Pictures == null || weibo.Pictures.Length == 0)
                {
                    UserLog.WriteNormalLog(userLable.DisplayName, "获取微博失败,类型不明确");
                    return;
                }

                //设置tags
                string weiboText = userLable.IsFrontTagsSet ?
                                   userLable.Tags + weibo.WeiboMessage :
                                   weibo.WeiboMessage + userLable.Tags;
                WeiboOperateTool.SendAnImageWeibo(userLable.Cookies, weiboText, weibo.Pictures);
            }
            else
            {
                this.richTextBox1.Text = this.richTextBox1.Text + userLable.DisplayName + " 微博库已空\n";
                EMailTool.SendMail("微博库已空", String.Format("用户昵称:{0}<br/>登录账号:{1}", userLable.DisplayName, userLable.UserName));
            }
        }