Example #1
0
        public static List <GroupInfo> GetGroupList2(ICoolQApi api)
        {
            List <GroupInfo> list = new List <GroupInfo>();

            try
            {
                //CQLogger.GetInstance().AddLog(string.Format("[↓][帐号] 取群列表", new object[0]));
                string          url             = "http://qun.qq.com/cgi-bin/qun_mgr/get_group_list";
                var             postData        = new Dictionary <string, string>();
                XJHTTP          xJHTTP          = new XJHTTP();
                CookieContainer cookieContainer = xJHTTP.StringToCookie("qun.qq.com", api.GetCookies());


                postData.Add("bkn", api.GetCsrfToken().ToString());
                HttpResults httpResults = xJHTTP.PostHtml(url, "http://qun.qq.com/member.html", "bkn=" + api.GetCsrfToken().ToString(), false, cookieContainer, 15000);

                string sourceString = httpResults.Html;
                MyLogUtil.ToLog(httpResults.Html);
                var                     strReg     = "{\"gc\":([1-9][0-9]{4,10}),\"gn\":\"(.*?)\",\"owner\":([1-9][0-9]{4,10})}";
                Regex                   reg        = new Regex(strReg);
                MatchCollection         matches    = reg.Matches(sourceString);
                MyJsonUtil <GroupInfo2> myJsonUtil = new MyJsonUtil <GroupInfo2>();
                foreach (Match match in matches)
                {
                    GroupInfo2 g = myJsonUtil.parseJsonStr(match.Value);
                    list.Add(new GroupInfo(g.gn, g.gc, g.owner));
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
                MyLogUtil.ErrToLog("获取群列表出现错误,原因:" + ex);
            }
            return(list);
        }
Example #2
0
        public static List <GroupInfo> GetGroupList(ICoolQApi api)
        {
            string content = api.CQ_getGroupList();

            MyLogUtil.ErrToLog("获取的群信息:" + content);
            return(ParseGroupList(content));
        }