Пример #1
0
        public static T jwc_largetable <T>()
        {
            JWCHttpHelper d = new JWCHttpHelper("http://inquiry.ecust.edu.cn/ecustedu/K_StudentQuery/K_BigScoreTableDetail.aspx?key=0");

            d.HttpGet();
            string html   = d.ToString();
            Regex  songti = new Regex("<font[^>]*>");

            html = songti.Replace(html, "");
            Regex zhiti = new Regex("</font>");

            html = zhiti.Replace(html, "");
            Regex regex = new Regex("<td align=\"center\" valign=\"middle\">[^<]*</td><td align=\"center\"" +
                                    " valign=\"middle\">(?<kemu>[^<]*)</td><td align=\"center\" valign=\"middle\">[^<]*" +
                                    "</td><td align=\"center\" valign=\"middle\">[^<]*</td><td align=\"center\" valign=\"middle\">" +
                                    "(?<fengshu>\\d+)</td><td align=\"center\" valign=\"middle\">[^<]*</td><td align=\"center\" " +
                                    "valign=\"middle\">[^<]*</td>"
                                    );
            MatchCollection mc = regex.Matches(html);

            if (typeof(T).Name.Equals("String"))
            {
                string result = "";
                foreach (Match item in mc)
                {
                    GroupCollection gc = item.Groups;
                    result = result + gc["kemu"].Value + ":" + gc["fengshu"].Value + "\n";
                }
                Regex jidian = new Regex("平均学分绩点:(?<jidian>\\d+(\\.\\d+)?)");
                result = result + "平均绩点:" + jidian.Match(html).Groups["jidian"].Value;
                return((T)(object)result);
            }
            else if (typeof(T).Name.Equals("JsonResult"))
            {
                Regex      jidian = new Regex("平均学分绩点:(?<jidian>\\d+(\\.\\d+)?)");
                JsonResult json   = new JsonResult();
                var        data   = new object[mc.Count + 1];
                data[0] = jidian.Match(html).Groups["jidian"].Value;
                for (int i = 1; i <= mc.Count; i++)
                {
                    GroupCollection gc      = mc[i - 1].Groups;
                    var             kemu    = gc["kemu"].Value;
                    var             fengshu = gc["fengshu"].Value;
                    data[i] = new { kemu, fengshu };
                }
                json.Data = data;
                json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                return((T)(object)json);
            }
            return(default(T));
        }
Пример #2
0
        public static T jwc_gradepoint <T>()
        {
            JWCHttpHelper e = new JWCHttpHelper("http://inquiry.ecust.edu.cn/ecustedu/K_StudentQuery/K_BigScoreTableDetail.aspx?key=0");

            e.HttpGet();
            string html   = e.ToString();
            Regex  jidian = new Regex("平均学分绩点:(?<jidian>\\d+(\\.\\d+)?)");

            if (typeof(T).Name.Equals("String"))
            {
                string result = jidian.Match(html).Groups["jidian"].Value;
                return((T)(object)result);
            }
            return(default(T));
        }
Пример #3
0
        public static void Login(string studentnum, string pwd)
        {
            if (HttpUtility.UrlDecode(pwd).Length > 10)
            {
                ErrorMsg = "您现在设置的教务处密码:" + HttpUtility.UrlDecode(pwd) + ",不正确。请重新输入jwc+您的教务处密码来解锁此功能,如jwc123456";
                return;
            }
            JWCHttpHelper a = new JWCHttpHelper("http://inquiry.ecust.edu.cn/ecustedu/K_StudentQuery/K_StudentQueryLogin.aspx");

            a.HttpGet();
            JWCHttpHelper    b     = new JWCHttpHelper("http://inquiry.ecust.edu.cn/ecustedu/Base/VerifyCode.aspx");
            Bitmap           input = b.HttpGetImage();
            IdentificatImage id    = new IdentificatImage(input);
            string           vc    = id.result;
            JWCHttpHelper    c     = new JWCHttpHelper("http://inquiry.ecust.edu.cn/ecustedu/K_StudentQuery/K_StudentQueryLogin.aspx");

            c.HttpPost("__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwULLTE2OTIxNDU0MTMPZBYCAgEPZBYCAgcPDxYCHgRUZXh0BVDlrabnlJ%2FliJ3lp4vlr4bnoIHkuLrouqvku73or4Hlj7flkI7lha3kvY3jgILlr4bnoIHplb%2FluqbkuI3otoXov4cxMOS4quWtl%2BespuOAgmRkZDanEMgmeoYOigCgOHJXPnTdIOtq&TxtStudentid=" + studentnum + "&TxtPassword="******"&txt_verifyCode=" + vc + "&BtnLogin=%E7%99%BB%E5%BD%95&__EVENTVALIDATION=%2FwEWBQKMjOWyBAKf8ICgBwLVqbaRCwLW2qK1CALi44eGDA67X3bLsDOxfx3HDe98WpJ8%2Bncw");
            string html = c.ToString();

            if (JWCHttpHelper.regexsuccess.IsMatch(html))
            {
                IsLogin = true;
                return;
            }
            else if (JWCHttpHelper.regexpwdfail.IsMatch(html))
            {
                ErrorMsg = "您现在设置的教务处密码:" + HttpUtility.UrlDecode(pwd) + ",不正确。请重新输入jwc+您的教务处密码来解锁此功能,如jwc123456";
                return;
            }
            else if (JWCHttpHelper.regexstudentnumfail.IsMatch(html))
            {
                ErrorMsg = "学生初始密码为身份证号后六位。密码长度不超过10个字符。";
                return;
            }
            else if (JWCHttpHelper.regexvcfail.IsMatch(html))
            {
                Login(studentnum, pwd);
            }
            ErrorMsg = "学号或密码错误";
            return;
        }