예제 #1
0
        public bool Comment(string url)
        {
            Send_Get Get  = new Send_Get(url);
            string   Page = "";

            if (Get.Get_Status())
            {
                Page = Get.Get_Output();
            }
            else
            {
                Page = "网络错误,请稍后再试!";
                return(false);
            }

            int             nums       = Convert.ToInt32(NumRegex.Match(Page).Value.Replace("value=", "").Replace("\"", ""));
            string          regexstr   = string.Format("name=\".+?\" value=\"{0}\"", nums);
            Regex           ValueRegex = new Regex(regexstr, RegexOptions.Multiline);
            MatchCollection Matchs     = ValueRegex.Matches(Page);//获取所有分数最高的标签
            List <string>   NameList   = new List <string>();

            foreach (Match i in Matchs)
            {
                NameList.Add(NameClassRegex.Match(i.Value).Value.Replace("\"", ""));
            }

            Regex input      = new Regex("<input type=\"hidden\" name=\"__VIEWSTATE\" value=\"(.*?)\" />");
            Regex inputname  = new Regex("name=\".*?\"");
            Regex inputvalue = new Regex("value=\".*?\"");

            string ViewState = input.Match(Page).Value;
            string postvalue = inputname.Match(ViewState).Value.Replace("name=\"", "").Replace("\"", "") + "=" + HttpUtility.UrlEncode(inputvalue.Match(ViewState).Value.Replace("value=\"", "").Replace("\"", ""));

            foreach (string i in NameList)
            {
                postvalue += "&" + HttpUtility.UrlEncode(i) + "=" + nums.ToString();
            }

            postvalue += "&txt_pjxx=&Button1=+%CC%E1+%BD%BB+";
            byte[] arrays = System.Text.Encoding.ASCII.GetBytes(postvalue);

            Send_Post Post = new Send_Post(url, url, arrays);

            if (Post.GetOutPut().IndexOf("提交成功") != -1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 获取用户姓名
        /// </summary>
        public static void GetUserName()
        {
            string   webcode = "";
            string   url     = "http://ojjx.wzu.edu.cn/xs_main.aspx?xh=" + UserAccount;
            Send_Get Get     = new Send_Get(url);

            webcode = Get.Get_Output();

            Regex hello     = new Regex("<span id=\"xhxm\">[\u4e00-\u9fa5]+</span></em>"); //匹配包含姓名的字符串
            Regex names     = new Regex("[\u4e00-\u9fa5]+");                               //匹配字符串内的中文
            Match match     = hello.Match(webcode);                                        //第一次匹配
            Match matchname = names.Match(match.ToString());                               //第二次匹配

            LoginInfo.UserName = matchname.ToString().Replace("同学", "");                   //匹配出姓名
        }
예제 #3
0
        private void GetPageStr()
        {
            Send_Get Get = new Send_Get(LoginInfo.SetUrl(LoginInfo.CommentCode));

            if (Get.Get_Status() == true)
            {
                PageStr = Get.Get_Output();
                if (PageStr.IndexOf("已经评价过") != -1)
                {
                    MessageBox.Show("已经完成评价任务,无需评教!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else if (PageStr.IndexOf("已关闭") != -1)
                {
                    MessageBox.Show("评教系统已关闭,请与相关部门联系!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            else
            {
                PageStr = "网络错误,请稍后重试!";
                return;
            }

            string          TableStr   = TableRegex.Match(PageStr).Value;
            MatchCollection ClassMatch = ClassRegex.Matches(TableStr);

            foreach (Match i in ClassMatch)
            {
                if (i.Value.IndexOf("onclick") == -1)
                {
                    continue;
                }

                NameStr.Add(NameRegex.Match(i.Value).Value.Replace("<td>", "").Replace("</td>", ""));      //课程名称
                LinkStr.Add(LinkRegex.Match(i.Value).Value.Replace("window.open('", "").Replace("'", "")); //链接
                if (i.Value.IndexOf("已评价") == -1)
                {
                    IsComment.Add(false);
                }
                else
                {
                    IsComment.Add(true);
                }
            }
        }
예제 #4
0
        private void GetList()
        {
            string url = LoginInfo.SetUrl(LoginInfo.GetClassNode);

            LoginInfo.PublicClassList.Clear();

            Send_Get get = new Send_Get(url);

            output = get.Get_Output();

            Regex TrRegex        = new Regex("<tr.*?>.+?</tr>", RegexOptions.Singleline);                                                 //确定具体课程的行
            Regex InputRegex     = new Regex("<input name=\".+?\" id=\".+?\" type=\"hidden\" value=\".+?\" />", RegexOptions.Singleline); //确定隐藏名称和值
            Regex ClassNameRegex = new Regex("<a href=.+?>.+?</a>", RegexOptions.Singleline);                                             //确定课程名称,有教材信息下标取1,反之取0
            Regex NumRegex       = new Regex("<td>\\d*?</td><td>\\d*?</td>", RegexOptions.Singleline);                                    //获取课程人数和剩余人数
            Regex TDRegex        = new Regex("\\d+", RegexOptions.Singleline);                                                            //分离人数
            Regex ParaRegex      = new Regex("\".+?\"", RegexOptions.Singleline);
            Regex ARegex         = new Regex("<a .+?>", RegexOptions.Singleline);

            MatchCollection TrMatch = TrRegex.Matches(output);

            for (int i = 1; i <= TrMatch.Count - 8; i++)
            {
                LoginInfo.OpenClassNode node = new LoginInfo.OpenClassNode();
                string          MatchOutput  = TrMatch[i].Value;
                MatchCollection ParaMatch    = ParaRegex.Matches(InputRegex.Match(MatchOutput).Value);
                node.HiddenName  = ParaMatch[0].Value.Replace("\"", "");
                node.HiddenValue = ParaMatch[3].Value.Replace("\"", "");
                MatchCollection ClassMatch = ClassNameRegex.Matches(MatchOutput);
                if (ClassMatch.Count >= 3)//获取课程名称
                {
                    node.NeedBook  = true;
                    node.ClassName = ClassMatch[1].Value.Replace(ARegex.Match(ClassMatch[1].Value).Value, "").Replace("</a>", "");
                    node.Teacher   = ClassMatch[2].Value.Replace(ARegex.Match(ClassMatch[2].Value).Value, "").Replace("</a>", "");
                }
                else
                {
                    node.NeedBook  = false;
                    node.ClassName = ClassMatch[0].Value.Replace(ARegex.Match(ClassMatch[0].Value).Value, "").Replace("</a>", "");
                    node.Teacher   = ClassMatch[1].Value.Replace(ARegex.Match(ClassMatch[1].Value).Value, "").Replace("</a>", "");
                }
                node.Count    = Convert.ToInt32(TDRegex.Matches(NumRegex.Match(MatchOutput).Value)[1].Value);
                node.Selected = false;
                LoginInfo.PublicClassList.Add(node);
            }
        }
예제 #5
0
        /// <summary>
        /// 初始化查询范围
        /// </summary>
        public static void InitYearOfTerm()
        {
            Regex  SelectForm = new Regex("<select name=\"xnd\".+?</select>", RegexOptions.Singleline);
            Regex  Time       = new Regex("\\d{4}-\\d{4}", RegexOptions.Singleline);
            string url        = SetUrl(ClassTableCode);
            string webcode    = "";

            Send_Get Get = new Send_Get(url);

            webcode = Get.Get_Output();

            MatchCollection TimeCollect = Time.Matches(webcode);

            for (int i = 0; i < TimeCollect.Count; i += 2)
            {
                YearsOfTerm.Add(TimeCollect[i].Value + "学年");
            }
            YearsOfTerm.Sort();
        }
예제 #6
0
        public GetClassTable(string year, string index)
        {
            WebCode   = "";
            IsSucceed = true;
            IsSame    = true;
            LoginInfo.ClassList.Clear();
            LoginInfo.MaxIndex = -1;
            TermYear           = year;  //形式暂定为\d{4}-\d{4}
            TermIndex          = index; //暂定为单个数字
            CT_Url             = LoginInfo.SetUrl(LoginInfo.ClassTableCode);
            Array.Clear(LoginInfo.ClassTable, 0, LoginInfo.ClassTable.Length);
            Send_Get Get = new Send_Get(CT_Url);

            if (Get.Get_Status() == false)
            {
                IsSucceed = false;
                return;
            }
            WebCode = Get.Get_Output();

            GetKeyTable();
        }
예제 #7
0
        public GetGrade(string Year, string Term)
        {
            LoginInfo.GradeList.Clear();
            WebCode     = "";
            Url         = LoginInfo.SetUrl(LoginInfo.GradeCode);
            YearOfGrade = Year;//\d{4}-\d{4}
            TermOfGrade = Term;
            IsSucceed   = true;
            IsEmpty     = true;

            Send_Get Get = new Send_Get(Url);

            if (Get.Get_Status() == false)
            {
                IsSucceed = false;
                return;
            }

            WebCode = Get.Get_Output();

            Send_GetGrade_Req();
        }
예제 #8
0
        /// <summary>
        /// 初始化成绩查询范围
        /// </summary>
        public static void InitGradeRange()
        {
            YearsOfGrade.Clear();
            string webcode = "";
            string url     = SetUrl(GradeCode);

            Send_Get Get = new Send_Get(url);

            webcode = Get.Get_Output();

            Regex SelectYear = new Regex("<select name=\"ddlXN\" id=\"ddlXN\">.+?</select>", RegexOptions.Singleline);
            Regex Range      = new Regex("\\d{4}-\\d{4}");

            Match           Select   = SelectYear.Match(webcode);
            MatchCollection RangeNum = Range.Matches(Select.Value);

            for (int i = 0; i < RangeNum.Count; i += 2)
            {
                YearsOfGrade.Add(RangeNum[i].Value + "学年");
            }
            YearsOfGrade.Sort();
        }