Ejemplo n.º 1
0
        public static bool MakeLogin(string userName, string passWord, string validateCode,out string errorMsg)
        {
            bool loginFlg = false;
            errorMsg = string.Empty;
            //string postString = "action=second&Username=13472553885&Password=leifengren&validatenum={0}";
            string postString = "action=second&Username={0}&Password={1}&validatenum={2}";
            HttpService web = new HttpService();
            string htmlContent = string.Empty;
            web.TargetUrl = string.Concat(Consts.URL_DEFAULT, Consts.URL_POST_LOGIN);
            web.Encode = Encoding.GetEncoding("gb2312");
            web.RefererUrl = Consts.URL_DEFAULT;
            web.PostData = string.Format(postString, userName, passWord, validateCode);
            web.PostHttpUseSession(ref htmlContent);
            if (htmlContent.IndexOf("login_ar") != -1)
            {
                MyService.MyInfo = HtmlParser.GetBaseInfo(htmlContent);
                loginFlg = true;
            }
            else if (htmlContent.IndexOf("login_un") != -1)
            {
                loginFlg = false;

                errorMsg = HtmlParser.GetLoginErrorMessage(htmlContent);
            }

            return loginFlg;
        }
Ejemplo n.º 2
0
        public static BaseInfo GetBaseInfo(string htmlContent)
        {
            BaseInfo baseInfo = new BaseInfo();
            ParserHtmlDocument doc = new ParserHtmlDocument();
            doc.LoadHtml(htmlContent);

            HtmlNode divs = doc.GetElementbyId("user_quit");

            if (divs != null)
            {
                Regex regex;
                //手机号码
                string temp = divs.SelectSingleNode("//span").InnerText;
                regex = new Regex(@"\d{6,11}");
                baseInfo.TelephoneNo = regex.Match(temp).Value;
                //上次登录时间
                temp = StringUtil.CutEmptyChar(divs.InnerText);
                regex = new Regex(@"(?<=(您上次登录的时间为:))[\w\W]*?(?=IP)");
                baseInfo.PreLogonTime = regex.Match(temp).Value;
                //上次登录IP
                regex = new Regex(@"\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}");
                baseInfo.LocalIpAddress = regex.Match(temp).Value;

                HtmlNodeCollection levelDiv = doc.GetElementbyId("list1").SelectNodes("div");
                foreach (HtmlNode node in levelDiv)
                {
                    string strClass = node.GetAttributeValue("class", "");
                    if (strClass == "text1")
                    {
                        temp = StringUtil.CutEmptyChar(node.InnerText);
                        //等级
                        regex = new Regex(@"(?<=(您的级别\s?))[\w\W]*?(?=(\s?充话费币余额))");
                        baseInfo.UserLevel = StringUtil.GetTelephoneNumberExceptSpace(regex.Match(temp).Value);
                        //剩余金额
                        regex = new Regex(@"\d+(\.\d+)?");

                        baseInfo.LeavePoing = Convert.ToDouble(regex.Match(temp).Value);
                        break;
                    }
                }
                MyService.MyInfo = baseInfo;
            }
            return baseInfo;
        }
Ejemplo n.º 3
0
 private MyService()
 {
     myInfo = new BaseInfo();
 }