Beispiel #1
0
        public void Test_AttitudesDestroy()
        {
            string res = CNHttpWork.AttitudesDestroy(CurrWebLogin.Web,
                                                     "http://m.weibo.cn/1454461772/C4SFndfzN", "C4SFndfzN".MidToId());

            Console.WriteLine(res);
        }//取消点赞
Beispiel #2
0
        public void Test_CommentMblog()
        {
            string res = CNHttpWork.CommentMblog(
                CurrWebLogin.Web, "http://m.weibo.cn/1454461772/C4SFndfzN",
                "C4SFndfzN".MidToId(), "我又来评论了", true);

            Console.WriteLine(res);
        }//评论
Beispiel #3
0
        public void Test_RetweetMblog()
        {
            string res = CNHttpWork.RetweetMblog(
                CurrWebLogin.Web, "http://m.weibo.cn/1454461772/C4SFndfzN",
                "C4SFndfzN".MidToId(), "呵呵 挺有意思!!!", true);

            Console.WriteLine(res);
        }//转发
Beispiel #4
0
        public void Test_GetWeiboHttpSearchUserIDs()
        {
            for (int i = 1925821007; i < 1935821007; i++)
            {
                var t = ApiHttpWork.Instance.GetUserEntityColloction("2415806241", i.ToString());
                var s = ApiHttpWork.Instance.GetTags("2415806241", i.ToString());
            }
            List <string> res = CNHttpWork.GetWeiboHttpSearchUserIDs(1, 0, 0, 0, "a");

            Console.WriteLine(res);
        }//GetWeiboHttpSearchUserIDs
Beispiel #5
0
        public void Test_AddMblog()
        {
            string res = CNHttpWork.AddMblog(CurrWebLogin.Web, "今天天气晴朗");

            Console.WriteLine(res);
        }//发微博
Beispiel #6
0
        public void Test_GetWeiboUserEntity()
        {
            Entity res = CNHttpWork.GetWeiboUserEntity("1454461772");

            Console.WriteLine(res);
        }//获取用户主页的信息
Beispiel #7
0
        public void Test_Exist()
        {
            bool res = CNHttpWork.Exist("1454461772");

            Console.WriteLine(res);
        }//检测用户是否存在
Beispiel #8
0
        public void Test_GetCommentNum()
        {
            var res = CNHttpWork.GetCommentNum(1454461772, "C4SFndfzN".MidToId());

            Console.WriteLine(res);
        }//获取一页微博的评论数量
Beispiel #9
0
        public void Test_SaveInformation()
        {
            string res = CNHttpWork.SaveInformation(CurrWebLogin.Web, "5171491789", "5553089850", "deanzhou12345678");

            Console.WriteLine(res);
        }//复制被克隆对象信息
Beispiel #10
0
        public void Test_RecevieDirectMessages()
        {
            List <CnDirectMessagesEntity> res = CNHttpWork.RecevieDirectMessages(CurrWebLogin.Web, "5553089850");

            Console.WriteLine(res);
        }//收发给自己的私信
Beispiel #11
0
        public void Test_FriendDestroy()
        {
            string res = CNHttpWork.FriendDestroy(CurrWebLogin.Web, "5171491789");

            Console.WriteLine(res);
        }//取消关注
Beispiel #12
0
        public void Test_UnfreezeByAvatar()
        {
            var res = CNHttpWork.UnfreezeByAvatar(CurrWebLogin.Web);

            Console.WriteLine(res);
        }//UnfreezeByAvatar [分析st失败]
Beispiel #13
0
 public void Test_GetMblog()
 {
     CommonEntityLib.Entities.status.Entity res = CNHttpWork.GetMblog(CurrWebLogin.Web, "http://m.weibo.cn/1454461772/C4SFndfzN");
     Console.WriteLine(res);
 }//根据m.weibo.cn博文地址获取博文信息
Beispiel #14
0
        public void Test_UserExist()
        {
            var res = CNHttpWork.UserExist(CurrWebLogin.Web, "5553089850");

            Console.WriteLine(res);
        }//根据uid判断用户是否存在
Beispiel #15
0
        public void Test_GetMblogs()
        {
            var res = CNHttpWork.GetMblogs(CurrWebLogin.Web, "1640057165");

            Console.WriteLine(res);
        }//根据用户uid获取最近10条微博
Beispiel #16
0
        public void Test_GetUserEntity()
        {
            var res = CNHttpWork.GetUserEntity(CurrWebLogin.Web, "5553089850");

            Console.WriteLine(res);
        }//获取用户信息
Beispiel #17
0
        public void Test_ReceiveComment()
        {
            var res = CNHttpWork.ReceiveComment(CurrWebLogin.Web, "5553089850");

            Console.WriteLine(res);
        }//收发给自己的评论
Beispiel #18
0
        /// <summary>
        /// 根据uid获取用户信息
        /// </summary>
        /// <param name="webLogin">登陆对象</param>
        /// <param name="uid"></param>
        /// <returns></returns>
        public CommonEntityLib.Entities.user.Entity GetUserEntity(IWeiboLogin webLogin, string uid)
        {
            IWeiboLogin cnWeiboLogin = PlatformType.CN.GetWeiboLogin();

            cnWeiboLogin.Web.Cookie = webLogin.Web.Cookie;

            if (!CNHttpWork.UserExist(cnWeiboLogin.Web, uid))
            {
                return(null);
            }

            CommonEntityLib.Entities.user.Entity res = CNHttpWork.GetUserEntity(cnWeiboLogin.Web, uid);
            if (res == null)
            {
                return(null);
            }

            string url  = "http://weibo.com/" + uid + "/info";
            string html = webLogin.Web.GetHTML(url);

            if (string.IsNullOrEmpty(html))
            {
                return(null);
            }

            var temHtmlList = new Dictionary <string, string>();

            if (html.Contains("<script>FM"))
            {
                var regex = new Regex(@"FM.view\((?<json>.*?)\)</script>");
                if (regex.IsMatch(html))
                {
                    foreach (Match match in regex.Matches(html))
                    {
                        string jsonStr = match.Groups["json"].Value;
                        if (!jsonStr.Contains("等级信息") && !jsonStr.Contains("基本信息") && !jsonStr.Contains("他的主页") && !jsonStr.Contains("Pl_Official_Headerv6__1"))
                        {
                            continue;
                        }

                        var    json  = DynamicJson.Parse(jsonStr);
                        string domid = json.domid;
                        try
                        {
                            string ht = json.html;
                            for (var i = (char)1; i < (char)32; i++)
                            {
                                ht = ht.Replace(i.ToString(CultureInfo.InvariantCulture), string.Empty);
                            }
                            ht = ht.Replace("\x7F", string.Empty);

                            temHtmlList.Add(domid, ht);
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }

            foreach (var thl in temHtmlList)
            {
                if (thl.Key.Contains("Pl_Official_Headerv6__1"))
                {
                    res.Verified = thl.Value.Contains("verified.weibo.com");
                    if (res.Verified)
                    {
                        HtmlDocument document = new HtmlDocument();
                        document.LoadHtml(thl.Value);
                        var root = document.DocumentNode;

                        res.VerifiedReason = root.SelectSingleNode("div/div/div[@class='shadow  S_shadow']/div[@class='pf_photo']/a/em")
                                             .Attributes["title"].Value;
                    }
                    continue;
                }

                if (thl.Value.Contains("等级信息"))
                {
                    // 等级
                    // <span>Lv.2</span>
                    string lv = Regex.Match(thl.Value, "<span>Lv\\.(?<lv>\\d*)</span>").Groups["lv"].Value;
                    int    uRank;
                    if (!string.IsNullOrEmpty(lv) && int.TryParse(lv, out uRank))
                    {
                        res.Urank = uRank;
                    }
                    continue;
                }

                if (thl.Value.Contains("他的主页"))
                {
                    HtmlDocument document = new HtmlDocument();
                    document.LoadHtml(thl.Value);
                    var root = document.DocumentNode;
                    var aTag = root.SelectSingleNode("div/div/table/tr/td/a");
                    if (aTag != null)
                    {
                        res.ProfileUrl = string.Format("http://weibo.com{0}", aTag.Attributes["href"].Value);
                    }
                }

                if (thl.Value.Contains("基本信息"))
                {
                    HtmlDocument document = new HtmlDocument();
                    document.LoadHtml(thl.Value);
                    var root = document.DocumentNode;
                    HtmlNodeCollection categoryNodeList = root.SelectNodes("//ul[@class='clearfix']/li");

                    if (categoryNodeList == null)
                    {
                        continue;
                    }

                    foreach (HtmlNode htmlNode in categoryNodeList)
                    {
                        HtmlNodeCollection spans = htmlNode.SelectNodes("span");
                        if (spans.Count != 2)
                        {
                            continue;
                        }

                        string txt = spans[0].InnerText;
                        string val = spans[1].InnerText;

                        if (txt.Contains("博客"))
                        {
                            res.Url = val;
                            continue;
                        }
                        if (txt.Contains("个性域名"))
                        {
                            res.Domain = val;
                            continue;
                        }
                        if (txt.Contains("注册时间"))
                        {
                            res.CreatedAt = val;
                            continue;
                        }
                        if (txt.Contains("所在地"))
                        {
                            res.Location = val;
                            if (!string.IsNullOrEmpty(res.Location) && res.Location.Split(' ').Count() >= 2)
                            {
                                string provice = res.Location.Split(' ')[0].Trim();
                                string city    = res.Location.Split(' ')[1].Trim();
                                res.Province = ProvinceToCode(provice);
                                res.City     = CityToCode(city);
                            }
                            continue;
                        }
                        if (txt.Contains("标签"))
                        {
                            HtmlNodeCollection tags = spans[1].SelectNodes("a");
                            if (tags != null)
                            {
                                res.Remark = string.Join(",", tags.Select(c => c.InnerText));
                            }
                        }
                    }
                }
            }
            return(res);
        }
Beispiel #19
0
        public void Test_BowenSpiderExecute()
        {
            var res = CNHttpWork.BowenSpiderExecute("1640057165");

            Console.WriteLine(res);
        }//获取博文列表 -- GetMblogs(Entity weiboUser, int page)【获取一页用户微博数据】
Beispiel #20
0
        public void Test_SendDirectMessages()
        {
            string res = CNHttpWork.SendDirectMessages(CurrWebLogin.Web, "5553089850", "这是一封我发出的私信");

            Console.WriteLine(res);
        }//发私信
        public Object[] jiefeng(string username, string password, string receive_sms_name, string receive_sms_account,
                                string receive_sms_password, string send_sms_name, string send_sms_account, string send_sms_password,
                                string type)
        {
            string      result = "";
            IWeiboLogin login  = new CNWeiboLogin();

            if (login.Web == null)
            {
                result = "SinaVisitorSystem失败";
            }
            try
            {
                login.WeiboLogin(username, password);
                string loginResult = login.Result;
                switch (loginResult)
                {
                case "正常":
                    result = "正常";
                    break;

                case "锁定":
                    result = "锁定";
                    break;

                case "死号":
                    result = "死号";
                    break;

                case "无法收短信解封":
                {
                    //Logger.Info("账号:{0}密码:{1},无法收短信解封", username, password);
                    if (type == "water")
                    {
                        result = loginResult;
                    }
                    else if (type == "small_weibo")
                    {
                        //login.Web.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)";
                        Unfreeze unfreeze = new Unfreeze(send_sms_name, send_sms_account, send_sms_password);
                        login = new ComWeiboLogin();
                        login.WeiboLogin(username, password);
                        result = unfreeze.Run(login.Web);
                    }
                    break;
                }

                case "封号":
                {
                    result = CNHttpWork.UnfreezeByAvatar(login.Web);
                    if (result == "分析st失败")
                    {
                        Unfreeze unfreeze = new Unfreeze(receive_sms_name, receive_sms_account, receive_sms_password);
                        login = new ComWeiboLogin();
                        login.WeiboLogin(username, password);
                        result = unfreeze.Run(login.Web);
                    }
                    break;
                }

                case "密码错误":
                    result = "密码错误";
                    break;

                default:
                    result = loginResult;
                    break;
                }
            }
            catch (Exception err)
            {
                result = err.Message;
                //File.AppendAllText("jiefengerr.txt", DateTime.Now + "\t" + err + "\t" + username + "\t" + password + Environment.NewLine);
            }
            return(new Object[] { login, result });
        }
Beispiel #22
0
        public void Test_GetSingleMblog()
        {
            var res = CNHttpWork.GetSingleMblog("http://m.weibo.cn/1640057165/sd");

            Console.WriteLine(res);
        }//根据微博Url获取微博内容页面
Beispiel #23
0
 /// <summary>
 /// 用户信息搜索
 /// </summary>
 /// <param name="factor1">类型:只搜公司 1 只搜学校 2 只搜标签 3</param>
 /// <param name="factor2">性别:男性 4  女性 5</param>
 /// <param name="factor3">用户类型:机构认证用户 6 个人认证用户 7 普通用户 8</param>
 /// <param name="factor4">年龄段:18以下_9 19到22_10 23到29_11 30到39_12 40以上_13</param>
 /// <param name="queryWord">查询字符串</param>
 /// <returns>符合条件的UserID列表</returns>
 public List <string> GetWeiboHttpSearchUserIDs(int factor1, int factor2, int factor3, int factor4, string queryWord)
 {
     return(CNHttpWork.GetWeiboHttpSearchUserIDs(factor1, factor2, factor3, factor4, queryWord));
 }
Beispiel #24
0
        public void Test_AttentionSpiderParallelExecute()
        {
            var res = CNHttpWork.AttentionSpiderParallelExecute("1640057165");

            Console.WriteLine(res);
        }//并行获取关注的UID列表 -- GetFollowers(Entity weiboUser, int page)【获取关注】 -- GetWeiboUser(string uid)【获取用户主页信息】