/// <summary> /// 发送两个Get请求获得我的评教信息 /// </summary> /// <param name="Http"></param> /// <returns></returns> public String GetMyEvaluation(JxglxtRequest Http) { String GetFrameUrl = "http://222.72.92.106/eams/evaluateStd.do"; String GetEvaluationUrl = ""; ///发送请求,获得评教页面的框架,从框架中获得关键Url Doc.LoadHtml(Http.GetRequest(GetFrameUrl)); GetEvaluationUrl = "http://222.72.92.106/eams/" + Doc.DocumentNode.SelectSingleNode("//*[@id='examTableFrame']").Attributes["src"].Value; //发送Get请求,获得评教相关的数据 //MyStream=new StreamReader(Http.GetRequest(GetEvaluationUrl)); //return DeleteHref(MyStream.ReadToEnd(),""); return(Http.GetRequest(GetEvaluationUrl)); }
/// <summary> /// 发送Get请求,获取我的成绩数据 /// </summary> /// <param name="Http">JxglRequest类</param> /// <returns>返回我的成绩的html字符串</returns> public String GetMyGrade(JxglxtRequest Http) { String GetGradeUrl = "http://222.72.92.106/eams/personGrade.do"; //MyStream = new StreamReader(Http.GetRequest(GetGradeUrl)); //return MyStream.ReadToEnd(); return(Http.GetRequest(GetGradeUrl)); }
/// <summary> /// 得到课表数据的方法,如果请求当前学期课表,则不需要传递PostData /// 如果请求其他学期,则需要传递PostData参数 /// </summary> /// <param name="Http">JxglRequest类</param> /// <param name="PostData">请求其他学期的课程表时传递的参数 /// 参数格式为calendar.year=2014-2015&calendar.term=1&startWeek=1</param> /// <returns>返回响应的字符串</returns> public String GetMyCourse(JxglxtRequest Http, String PostData = null) { ///先发送一个Get请求获得相关参数 GetYearInfo(Http); ///如果不传递PostData参数,则认为是第一次请求课程表,即获得最新的课程表 if (PostData == null) { //获得得到课表内容的Get请求的Url,Doc对象已经在GetYearInfo()方法中赋值 GetCourseUrl = Doc.DocumentNode.SelectSingleNode("//*[@id='contentListFrame']").Attributes["src"].Value.Trim(); //发送Get请求,获得我的课程的数据。 return(Http.GetRequest("http://222.72.92.106/eams/" + GetCourseUrl)); } //如果PostData不为null,则先发送Post请求再发送Get请求 else { //获得得到课表框架的Post请求的Url int a = GetCourseUrl.LastIndexOf("&"); int b = GetCourseUrl.LastIndexOf("ids=") + 4; PostFrameUrl = "http://222.72.92.106/eams/courseTableForStd.do?method=stdHome&setting.forCalendar=0&setting.kind=std&ids=" + GetCourseUrl.Substring(b, a - b); //构造PostData StringBuilder _PostData = new StringBuilder(); _PostData.Append("calendar.studentType.id="); _PostData.Append(StudengTypeId); _PostData.Append("&ignoreHead="); _PostData.Append(IgnoreHead); _PostData.Append("&calendar.id="); _PostData.Append(CalendarId); _PostData.Append("&"); _PostData.Append(PostData); //发送Post请求 Doc.LoadHtml(Http.PostRequest(PostFrameUrl, _PostData.ToString())); //获得得到课表内容的Get请求的Url GetCourseUrl = Doc.DocumentNode.SelectSingleNode("//*[@id='contentListFrame']").Attributes["src"].Value; //发送Get请求,获得我的课程的数据。 MyStream = new StreamReader(Http.GetRequest("http://222.72.92.106/eams/" + GetCourseUrl)); //return DeleteHref(MyStream.ReadToEnd(),""); return(MyStream.ReadToEnd()); }//PostData is not null }
/// <summary> /// 发送Get请求获得学年、学期、学生类别等参数值 /// </summary> /// <param name="Http"></param> private void GetYearInfo(JxglxtRequest Http) { ///先发送一个Get请求获得相关参数 String GetFrameUrl = "http://222.72.92.106/eams/courseTableForStd.do?method=stdHome"; //发送Get请求,并用HtmlAgilityPack解析htm Doc.LoadHtml(Http.GetRequest(GetFrameUrl)); StudengTypeId = Doc.DocumentNode.SelectSingleNode("//*[@name='calendar.studentType.id']/option").Attributes["value"].Value; IgnoreHead = Doc.DocumentNode.SelectSingleNode("//*[@name='ignoreHead']").Attributes["value"].Value; CalendarId = Doc.DocumentNode.SelectSingleNode("//*[@name='calendar.id']").Attributes["value"].Value; CalendarYear = Doc.DocumentNode.SelectSingleNode("//*[@id='year']/option").Attributes["value"].Value; CalendarTerm = Doc.DocumentNode.SelectSingleNode("//*[@id='term']/option").Attributes["value"].Value; //获得得到课表内容的Get请求的Url GetCourseUrl = Doc.DocumentNode.SelectSingleNode("//*[@id='contentListFrame']").Attributes["src"].Value.Trim(); }
/// <summary> /// 得到学业预警信息 /// </summary> /// <param name="Http"></param> /// <param name="UserNumber"></param> /// <returns></returns> public String GetAlertInfo(JxglxtRequest Http, String UserNumber) { Regex rex = new Regex("^[0-9]{11}$"); if (rex.IsMatch(UserNumber)) { String Url = "http://eval.ecupl.edu.cn/studentIndexWarning/" + UserNumber; Doc.LoadHtml(Http.GetRequest(Url)); return(Doc.DocumentNode.SelectSingleNode("//*[@id='sw']").InnerHtml); } else { return(""); } }
//内网:http://192.168.100.54/eams/index.do?isShowLogin=true //外网:http://222.72.92.106/eams/index.do?isShowLogin=true static void Main(string[] args) { String CookieGetUrl = "http://222.72.92.106/eams/index.do?isShowLogin=true"; String LoginPostUrl = "http://222.72.92.106/eams/login.do"; String LoginPostData = "name=12042201028&isShowLogin=true&password=sw123456&lang=chinese"; String HomePageGetUrl = "http://222.72.92.106/eams/defaultHome.do?method=welcome"; String PersonGradeGetUrl = "http://222.72.92.106/eams/personGrade.do"; String PersonCourseGetUrl = "http://222.72.92.106/eams/courseTableForStd.do?method=stdHome"; String CourseSearchPostUrl = "http://222.72.92.106/eams/teachTaskSearch.do?method=arrangeInfoList"; String RoomSearchPostUrl = "http://222.72.92.106/eams/roomResource.do?method=search"; String ContentType = "application/x-www-form-urlencoded"; JxglxtRequest Http = new JxglxtRequest(); CourseEntry Ce = new CourseEntry(); RoomEntry Re = new RoomEntry(); //发送Post请求,传递用户认证信息 var aa = Http.LoginJxglxt(LoginPostUrl, LoginPostData); String str = "pageNo=1&pageSize=1&calendar.id=341&calendar.studentType.id=5&calendar.term=1&task.seqNo=&task.course.code=&task.course.name=&task.courseType.name=&task.teachClass.depart.id=&task.arrangeInfo.teachDepart.id=&teacher.name=&teacher.department.id=&task.teachClass.enrollTurn=&task.teachClass.stdType.id=&courseActivity.time.week=&courseActivity.time.startUnit="; var bb = Http.PostRequest("http://222.72.92.106/eams/teachTaskSearch.do?method=arrangeInfoList", str); var cc = Http.GetRequest("http://222.72.92.106/eams/courseTableForStd.do?method=stdHome"); JxglxtInfo Info = new JxglxtInfo(); var dd = Info.GetMyCourse(Http); Http.Close(); }