Beispiel #1
0
        public void Submit()
        {
            Regex input      = new Regex("input type=\"hidden\" name=\".*?\" value=\".*?\"");
            Regex inputname  = new Regex("name=\".*?\"");
            Regex inputvalue = new Regex("value=\".*?\"");

            MatchCollection PageMatch = input.Matches(PageStr);
            string          poststr   = "";

            foreach (Match i in PageMatch)
            {
                string name  = HttpUtility.UrlEncode(inputname.Match(i.Value).Value.Replace("name=\"", "").Replace("\"", ""));
                string value = HttpUtility.UrlEncode(inputvalue.Match(i.Value).Value.Replace("value=\"", "").Replace("\"", ""));
                poststr += name + "=" + value + "&";
            }

            poststr += "btn_tj=+%CC%E1+%BD%BB+";

            byte[] array = System.Text.Encoding.ASCII.GetBytes(poststr);

            Send_Post Post = new Send_Post(LoginInfo.SetUrl(LoginInfo.CommentCode), LoginInfo.SetUrl(LoginInfo.CommentCode), array);

            if (Post.GetOutPut().IndexOf("完成评价") != -1)
            {
                MessageBox.Show("一键评教完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("提交结果出现问题,请自行登陆教务系统确认是否完成评教!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #2
0
        private void Send_GetGrade_Req()
        {
            string PostValue;
            Regex  input      = new Regex("input type=\"hidden\" name=\".*?\" value=\".*?\"");
            Regex  inputname  = new Regex("name=\".*?\"");
            Regex  inputvalue = new Regex("value=\".*?\"");
            Regex  Time       = new Regex("\\d{4}");

            Match yearmatch = Time.Match(YearOfGrade);

            MatchCollection inputmatch = input.Matches(WebCode);

            PostValue  = inputname.Match(inputmatch[0].Value).ToString().Replace("name=\"", "").Replace("\"", "") + "=xnd&" + inputname.Match(inputmatch[1].Value).ToString().Replace("name=\"", "").Replace("\"", "") + "=&" + inputname.Match(inputmatch[2].Value).ToString().Replace("name=\"", "").Replace("\"", "") + "=" + inputvalue.Match(inputmatch[2].Value).ToString().Replace("name=\"", "").Replace("\"", "").Replace("+", "%2b") + "&hidLanguage=&ddlXN=";
            PostValue += yearmatch.Value + "-" + Convert.ToString(Convert.ToInt32(yearmatch.Value) + 1) + "&ddlXQ=" + TermOfGrade + "&ddl_kcxz=&btn_xq=%D1%A7%C6%DA%B3%C9%BC%A8";
            PostValue  = PostValue.Replace("value=", "");
            byte[] bytes = System.Text.Encoding.UTF8.GetBytes(PostValue);

            Send_Post Post = new Send_Post(Url, Url, bytes);

            if (Post.GetStatus() == false)
            {
                IsSucceed = false;
                return;
            }

            WebCode = Post.GetOutPut();

            RegexGrade();
        }
Beispiel #3
0
        private void LoginToEA()
        {
            Regex     reg           = new Regex("<input type=\"hidden\" name=\"__VIEWSTATE\" value=\"(.*?)\" />");
            string    PostString    = "";
            string    ViewStateCode = "";
            Send_Post Post;

            #region 登陆主页获取网页内容
            HttpWebRequest GetStateCode   = (HttpWebRequest)HttpWebRequest.Create(LoginUrl);                              //连接主页
            WebResponse    result         = GetStateCode.GetResponse();                                                   //获取响应
            Stream         receviceStream = result.GetResponseStream();                                                   //创建IO流
            StreamReader   readerOfStream = new StreamReader(receviceStream, System.Text.Encoding.GetEncoding("gb2312")); //创建流读取器
            string         strHTML        = readerOfStream.ReadToEnd();                                                   //获取网页内容
            readerOfStream.Close();
            receviceStream.Close();
            result.Close();//关闭流
            #endregion

            #region 匹配ViewState
            Match whatstate = reg.Match(strHTML);                 //创建匹配VIEWSTATE的正则表达式
            ViewStateCode = whatstate.Groups[1].Value;            //匹配结果
            ViewStateCode = HttpUtility.UrlEncode(ViewStateCode); //URL编码
            PostString    = "__VIEWSTATE=" + ViewStateCode + "&txtUserName="******"&Textbox1=&TextBox2=" + UserPassword + "&txtSecretCode=" + SecertCode + "&RadioButtonList1=%D1%A7%C9%FA" + "&Button1=&lbLanguage=&hidPdrs=&hidsc=";
            byte[] bytes = System.Text.Encoding.UTF8.GetBytes(PostString);
            #endregion

            Post   = new Send_Post(LoginUrl, LoginUrl, bytes);
            Output = Post.GetOutPut();

            if (Output.IndexOf("验证码") == -1)
            {
                LoginStatus            = "OK";
                LoginInfo.LoginSucceed = true;
            }
            else//OK为登陆成功,InvalidCode为验证码错误,InvalidPassword为密码错误,InvalidAccount为帐号不存在或者被限制,UnknownError为未知错误
            {
                if (Output.IndexOf("验证码不正确") != -1)
                {
                    LoginStatus = "InvalidCode";
                }
                else if (Output.IndexOf("密码错误") != -1)
                {
                    LoginStatus = "InvalidPassword";
                }
                else if (Output.IndexOf("用户名不存在") != -1)
                {
                    LoginStatus = "InvalidAccount";
                }
                else
                {
                    LoginStatus = "UnknownError";
                }
                LoginInfo.LoginSucceed = false;
            }
        }
Beispiel #4
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);
            }
        }
Beispiel #5
0
        public string GetClasss(string classname)
        {
            GetPara(classname);

            string url = LoginInfo.SetUrl(LoginInfo.GetClassNode);

            byte[] array = System.Text.Encoding.GetEncoding("gb2312").GetBytes(sqlpara);

            Send_Post post = new Send_Post(url, url, array);

            Regex  Alert  = new Regex("alert\\('.+?'\\)", RegexOptions.Multiline);
            string output = Alert.Match(post.GetOutPut()).Value.Replace("alert('", "").Replace("')", "");

            return(output);
        }
Beispiel #6
0
        private void GetKeyTable()
        {
            string PostValue  = "";
            Regex  input      = new Regex("input type=\"hidden\" name=\".*?\" value=\".*?\"");
            Regex  inputname  = new Regex("name=\".*?\"");
            Regex  inputvalue = new Regex("value=\".*?\"");
            Regex  SelectYear = new Regex("<option selected=\"selected\" value=\"\\d+-\\d+\">");
            Regex  SelectTerm = new Regex("<option selected=\"selected\" value=\"\\d\">");
            Regex  Years      = new Regex("\\d{4}");

            Match  YearMatch = SelectYear.Match(WebCode);
            Match  TermMatch = SelectTerm.Match(WebCode);
            string Year      = YearMatch.Value;
            string Term      = TermMatch.Value;



            if (Year.IndexOf(TermYear) != -1 && Term.IndexOf(TermIndex) != -1)
            {
                RegexClassTable();
                return;
            }

            MatchCollection inputmatch = input.Matches(WebCode);
            Match           yearmatch  = Years.Match(TermYear);

            PostValue  = inputname.Match(inputmatch[0].Value).ToString().Replace("name=\"", "").Replace("\"", "") + "=xnd&" + inputname.Match(inputmatch[1].Value).ToString().Replace("name=\"", "").Replace("\"", "") + "=&" + inputname.Match(inputmatch[2].Value).ToString().Replace("name=\"", "").Replace("\"", "") + "=" + inputvalue.Match(inputmatch[2].Value).ToString().Replace("name=\"", "").Replace("\"", "").Replace("+", "%2b") + "&xnd=";
            PostValue += yearmatch.Value + "-" + Convert.ToString(Convert.ToInt32(yearmatch.Value) + 1) + "&xqd=" + TermIndex;
            PostValue  = PostValue.Replace("value=", "");
            byte[] bytes = System.Text.Encoding.UTF8.GetBytes(PostValue);

            Send_Post Post = new Send_Post(CT_Url, CT_Url, bytes);

            if (Post.GetStatus() == false)
            {
                IsSucceed = false;
                return;
            }
            WebCode = Post.GetOutPut();

            if (WebCode.IndexOf("您本学期课所选学分小于") != -1)
            {
                IsSame = false;
                return;
            }

            RegexClassTable();
        }