public ProfessionChoose() { InitializeComponent(); this.Title = "欢迎你:" + Student.StuName + "同学!"; string refer_str = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xs_main.aspx?xh=" + Student.StuNum; requestUriString = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xf_xsyxxxk.aspx?xh=" + Student.StuNum + "&xm=" + System.Web.HttpUtility.UrlEncode(Student.StuNum, Encoding.GetEncoding("GB2312")) + "&gnmkdm=N121110"; //post请求的数据 string html = SimilateSendPostDate.SimilateAndGetDataWithRefer("", refer_str, requestUriString); //向服务器请求登录页面的信息,获取ViewStae控制状态记录,然后用正则表达式提取 Regex regex = new Regex("name=\"__VIEWSTATE\" value=\".*\"\\s*/>"); Match match = regex.Match(html); viewState = System.Web.HttpUtility.UrlEncode(match.Value.Replace("name=\"__VIEWSTATE\" value=\"", "").Replace("\"", "").Replace("/>", "").Trim()); MatchCollection matches = new Regex("id=\"kcmcGrid__(?<text>.*?)_jc\"([\\s\\S]*?)<a [\\w\\W]*?>(?<text1>.*?)</a>").Matches(html); if (matches.Count > 0) { for (int i = 0; i < matches.Count; i++) { string key = matches[i].Groups["text"].Value; string value = matches[i].Groups["text1"].Value; dic_Course.Add(key, value); } } cbo_Course.ItemsSource = dic_Course.Values; cbo_Course.SelectedIndex = 1; }
public void Choose() { string html = ""; Dispatcher.Invoke((Action) delegate { do { string key = dic_Course.FirstOrDefault(x => x.Value.ToString() == cbo_Course.SelectedValue.ToString()).Key.ToString(); string postData = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=" + viewState + "&ddl_ywyl=&ddl_kcgs=&ddl_sksj=&ddl_xqbs=1&kcmcGrid%3A_" + key + "%3Axk=on&Button1=+%CC%E1+%BD%BB+"; string referRequest_str = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xf_xsyxxxk.aspx?xh=" + Student.StuNum + "&xm=" + System.Web.HttpUtility.UrlEncode(Student.StuName, Encoding.GetEncoding("GB2312")) + "&gnmkdm=N121110"; html = SimilateSendPostDate.SimilateAndGetDataWithRefer(postData, referRequest_str, referRequest_str); if (html.IndexOf("现在不是选课时间!") > 0) { status += "现在还不是选课时间\n"; Txb_Status.Text = status; MessageBox.Show("现在不是选课时间,请耐心等候!"); progressbar.Visibility = Visibility.Collapsed; return; } }while (html.IndexOf("请重新登陆,如无法解决,请稍后再试") > 0 || html.IndexOf("该门课程已选") < 0); if (html.IndexOf("该门课程已选") > 0) { MessageBox.Show("选课成功!"); } else { MessageBox.Show("好像没选成功!"); } progressbar.Visibility = Visibility.Collapsed; }); }
private void ChooseLesson() { string postData = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=" + viewState + "&ddl_kcxz=&ddl_ywyl=%D3%D0&ddl_kcgs=&ddl_xqbs=1&ddl_sksj=&TextBox1="; foreach (CourseMsg item in list_courseMsg) { postData += "&kcmcGrid%3A_ct" + item.CourseId + "%3Ajcnr=%7C%7C%7C"; if (item.IsChecked != "False") { postData += "&kcmcGrid%3A_ct" + item.CourseId + "%3Axk=on"; } } postData += "&dpkcmcGrid%3AtxtChoosePage=1&dpkcmcGrid%3AtxtPageSize=6&Button1=++%CC%E1%BD%BB++"; string referStr = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xf_xsqxxxk.aspx?xh=" + Student.StuNum + "&xm=" + System.Web.HttpUtility.UrlEncode(Student.StuName, Encoding.GetEncoding("GB2312")) + "&gnmkdm=N121109"; string rHtmlp = ""; do { rHtmlp = SimilateSendPostDate.SimilateAndGetDataWithRefer(postData, referStr, referStr); if (rHtmlp.IndexOf("现在不是选课时间") > 0) { MessageBox.Show("现在不是选课时间!"); tip.Visibility = Visibility.Collapsed; return; } else if (rHtmlp.IndexOf("该门课程已选") > 0) { MessageBox.Show("该门课程已选,请谢谢我qq50595531"); tip.Visibility = Visibility.Collapsed; return; } } while (rHtmlp.IndexOf("请重新登陆,如无法解决,请稍后再试") > 0 || rHtmlp.IndexOf("该门课程已选") < 0); //while (rHtmlp.IndexOf("请重新登陆,如无法解决,请稍后再试") > 0 || rHtmlp.IndexOf("该门课程已选") < 0 || rHtmlp.IndexOf("现在还不是选课时间") > 0); }
/// <summary> /// 绑定评价的详细数据 /// </summary> /// <param name="url"></param> private void BindEvaluateData() { string requestStr = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/" + list_Url[cmb_ClassName.SelectedIndex]; string htmlDetail = SimilateSendPostDate.SimilateGetData(requestStr); //向服务器请求登录页面的信息,获取ViewStae控制状态记录,然后用正则表达式提取 Regex regex_ViewState = new Regex("name=\"__VIEWSTATE\" value=\".*\"\\s*/>"); Match match = regex_ViewState.Match(htmlDetail); viewState = System.Web.HttpUtility.UrlEncode(match.Value.Replace("name=\"__VIEWSTATE\" value=\"", "").Replace("\"", "").Replace("/>", "").Trim()); Regex regex = new Regex("<td>[\\w\\W]*?</td><td>(?<id>[\\d].*?)</td><td>(?<content>.*?)</td><td> </td><td>(?<highPoint>.*?)</td><td>"); MatchCollection match_Detail = regex.Matches(htmlDetail); list_EvaluateDetail.Clear(); for (int i = 0; i < match_Detail.Count; i++) { EvaluateDetail evaluateDetail = new EvaluateDetail() { id = match_Detail[i].Groups["id"].Value.ToString(), content = match_Detail[i].Groups["content"].Value.ToString(), highPoint = match_Detail[i].Groups["highPoint"].Value.ToString(), point = match_Detail[i].Groups["highPoint"].Value.ToString() }; list_EvaluateDetail.Add(evaluateDetail); } grid_DataDetail.ItemsSource = list_EvaluateDetail; txb_Tip.Text = "你现在评价的是:" + cmb_ClassName.SelectedValue.ToString() + "的" + cmb_TeacherName.SelectedValue.ToString() + "老师:"; }
private void Btn_SelectAll_Click(object sender, RoutedEventArgs e) { for (int i = 0; i < dic_ClassAndTeacher.Count; i++) { string postData = "__VIEWSTATE=" + viewState + "&DataGrid1%3A_ctl2%3Atxt_pf=" + list_EvaluateDetail[0].point + "&DataGrid1%3A_ctl3%3Atxt_pf=" + list_EvaluateDetail[1].point + "&DataGrid1%3A_ctl4%3Atxt_pf=" + list_EvaluateDetail[2].point + "&DataGrid1%3A_ctl5%3Atxt_pf=" + list_EvaluateDetail[3].point + "&DataGrid1%3A_ctl6%3Atxt_pf=" + list_EvaluateDetail[4].point + "&DataGrid1%3A_ctl7%3Atxt_pf=" + list_EvaluateDetail[5].point + "&DataGrid1%3A_ctl8%3Atxt_pf=" + list_EvaluateDetail[6].point + "&DataGrid1%3A_ctl9%3Atxt_pf=" + list_EvaluateDetail[7].point + "&DataGrid1%3A_ctl10%3Atxt_pf=" + list_EvaluateDetail[8].point + "&DataGrid1%3A_ctl11%3Atxt_pf=" + list_EvaluateDetail[9].point + "&DataGrid1%3A_ctl12%3Atxt_pf=" + list_EvaluateDetail[10].point + "&txt_pjxx=" + Rtxb_whole.Text + "&Button1=%B1%A3++%B4%E6&TextBox1="; string requestStr = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/" + list_Url[i]; string Responsehtml = SimilateSendPostDate.SimilateGetDataByPost(postData, requestStr); } MessageBox.Show("全部评价成功!别忘了进网页提交确定评价!"); }
private void btn_SearchAll_Click(object sender, RoutedEventArgs e) { do { string referStr = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xf_xsqxxxk.aspx?xh=" + Student.StuNum + "&xm=" + System.Web.HttpUtility.UrlEncode(Student.StuName, Encoding.GetEncoding("GB2312")) + "&gnmkdm=N121109"; string postData = "__EVENTTARGET=dpkcmcGrid%3AtxtPageSize&__EVENTARGUMENT=&__VIEWSTATE=" + viewState + "&ddl_kcxz=&ddl_ywyl=%D3%D0&ddl_kcgs=&ddl_xqbs=1&ddl_sksj=&TextBox1=&kcmcGrid%3A_ctl2%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl3%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl4%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl5%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl6%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl7%3Ajcnr=%7C%7C%7C&dpkcmcGrid%3AtxtChoosePage=1&dpkcmcGrid%3AtxtPageSize=1000"; responseHtml = SimilateSendPostDate.SimilateAndGetDataWithRefer(postData, referStr, requestStr); } while (responseHtml.IndexOf("出错啦!") > 0 || responseHtml.IndexOf("三秒防刷") > 0); BindCourse(); }
private void BindTtile() { string referStr = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xs_main.aspx?xh=" + Student.StuNum; requestStr = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xf_xsqxxxk.aspx?xh=" + Student.StuNum + "&xm=" + System.Web.HttpUtility.UrlEncode(Student.StuName, Encoding.GetEncoding("GB2312")) + "&gnmkdm=N121109"; do { responseHtml = SimilateSendPostDate.SimilateAndGetDataWithRefer("", referStr, requestStr); }while (responseHtml.IndexOf("出错啦!") > 0 || responseHtml.IndexOf("三秒防刷") > 0); //课程属性提取 Regex CBregex = new Regex("<select name=\"ddl_kcgs\"[\\w\\W]*?id=\"ddl_kcgs\">(?<text>[\\w\\W]*?)</select> "); Match CBmatch = CBregex.Match(responseHtml); if (CBmatch.Success) { string str = CBmatch.Groups["text"].Value.Trim(); CourseBelong = str.Split(new string[] { "</option>" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < CourseBelong.Length; i++) { CourseBelong[i] = CourseBelong[i].Remove(0, CourseBelong[i].IndexOf(">") + 1); } cbx_CourseBelong.ItemsSource = CourseBelong; } //上课时间提取 Regex TCTregex = new Regex("<select name=\"ddl_sksj\"[\\w\\W]*?id=\"ddl_sksj\">(?<text>[\\w\\W]*?)</select> "); Match TCYmatch = TCTregex.Match(responseHtml); if (CBmatch.Success) { string str = TCYmatch.Groups["text"].Value.Trim(); TakeCourseTime = str.Split(new string[] { "</option>" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < TakeCourseTime.Length; i++) { TakeCourseTime[i] = TakeCourseTime[i].Remove(0, TakeCourseTime[i].IndexOf(">") + 1); } cbx_TakeCourseTime.ItemsSource = TakeCourseTime; } BindCourse(); //向服务器请求登录页面的信息,获取ViewStae控制状态记录,然后用正则表达式提取 Regex regex = new Regex("name=\"__VIEWSTATE\" value=\".*\"\\s*/>"); Match match = regex.Match(responseHtml); viewState = System.Web.HttpUtility.UrlEncode(match.Value.Replace("name=\"__VIEWSTATE\" value=\"", "").Replace("\"", "").Replace("/>", "").Trim()); cbx_CourseBelong.SelectedValue = ""; cbx_TakeCourseTime.SelectedValue = ""; isPostBack = false; }
private void SearchData(object sender, RoutedEventArgs e) { do { if (requestStr == "") { return; } string referStr = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xf_xsqxxxk.aspx?xh=" + Student.StuNum + "&xm=" + System.Web.HttpUtility.UrlEncode(Student.StuName, Encoding.GetEncoding("GB2312")) + "&gnmkdm=N121109"; string postData = "__EVENTTARGET=dpkcmcGrid%3AtxtPageSize&__EVENTARGUMENT=&__VIEWSTATE=" + viewState + "&ddl_kcxz=&ddl_ywyl=" + System.Web.HttpUtility.UrlEncode(IsHave, Encoding.GetEncoding("GB2312")) + "&ddl_kcgs=" + System.Web.HttpUtility.UrlEncode(courseBelongs, Encoding.GetEncoding("GB2312")) + "&ddl_xqbs=1&ddl_sksj=" + System.Web.HttpUtility.UrlEncode(courserTime, Encoding.GetEncoding("GB2312")) + "&TextBox1=" + System.Web.HttpUtility.UrlEncode(courseName, Encoding.GetEncoding("GB2312")) + "&Button2=%C8%B7%B6%A8&kcmcGrid%3A_ctl2%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl3%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl4%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl5%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl6%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl7%3Ajcnr=%7C%7C%7C&dpkcmcGrid%3AtxtChoosePage=1&dpkcmcGrid%3AtxtPageSize=1000"; responseHtml = SimilateSendPostDate.SimilateAndGetDataWithRefer(postData, referStr, requestStr); } while (responseHtml.IndexOf("出错啦!") > 0); BindCourse(); }
/// <summary> /// 绑定课程名称和任课老师数据 /// </summary> private void BindClassAndTeacher() { string referStr = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xs_main.aspx?xh=" + Student.StuNum; string requestStr = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xsjxpj2.aspx?xh=" + Student.StuNum + "&xm=" + System.Web.HttpUtility.UrlDecode(Student.StuName, Encoding.GetEncoding("GB2312")) + "&gnmkdm=N121901"; string htmlData = SimilateSendPostDate.SimilateAndGetDataWithRefer("", referStr, requestStr); Regex regex = new Regex("<td>(?<className>.*?)</td><td><a href='#' onclick=\"window.open\\('(?<url>[\\w\\W]*?)','xsjxpj','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1'\\)\"> (?<teacherName>.*?) </a></td>"); MatchCollection matchCollection = regex.Matches(htmlData); dic_ClassAndTeacher.Clear(); for (int i = 0; i < matchCollection.Count; i++) { dic_ClassAndTeacher.Add(matchCollection[i].Groups["className"].Value.ToString().Replace("【课堂教学】", ""), matchCollection[i].Groups["teacherName"].Value.ToString().Replace("</font>", "").Replace("<font color='#FF0000'>", "")); list_Url.Add(matchCollection[i].Groups["url"].Value.ToString()); } cmb_ClassName.ItemsSource = dic_ClassAndTeacher.Keys; cmb_TeacherName.ItemsSource = dic_ClassAndTeacher.Values; }