diff --git a/README.md b/README.md index be4fbe8..e7cc940 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # UCAS Helper ![python version](https://img.shields.io/badge/python-3.5%2B-blue) -![demo version](https://img.shields.io/badge/version-2.0.3-yellowgreen) +![demo version](https://img.shields.io/badge/version-2.0.4-brightgreen) ![license](https://img.shields.io/badge/license-GNU%20v3-yellowgreen) ```angular2 ********************************************************************************* @@ -10,7 +10,7 @@ ** # # # ####### # # # # # # # # # ** ** ### ### ## ## ### # # ### ##### # ### # # ** ** copyright@GentleCP ** -** version: 2.0.3 ** +** version: 2.0.4 ** ** github: https://github.com/GentleCP/UCASHelper ** ** 1:course sources download ** ** 2:wifi login ** @@ -79,6 +79,7 @@ ![](img/1.7.0.png) # 2. 更新日志 +- [2.0.4] 修复评估教师失败的bug - [2.0.3] 修复了部分课程因html解析不当导致的课程资源无法下载的情况,本次更新需要用到新的依赖包`lxml=4.5.2`, 已安装老版本的请重新执行`pip install -r requirements.txt` - [2.0.2] 修复了因课程网站选课系统添加头部检查导致的**课程评估,分数查询**功能的失效。 diff --git a/core/assess.py b/core/assess.py index e04c950..e46d003 100644 --- a/core/assess.py +++ b/core/assess.py @@ -105,7 +105,7 @@ def _assess_courses(self, course_ids): def _get_teacher_ids(self): # 通过课程评估url得到教师评估url teacher_assess_url = self._course_assess_url.replace('course','teacher') - res = self._S.get(teacher_assess_url) + res = self._S.get(teacher_assess_url, headers=self.headers) bs4obj = BeautifulSoup(res.text, 'html.parser') urls = [url.get('href') for url in bs4obj.find_all('a', {'class': 'btn'})] teacher_ids = [] @@ -119,7 +119,7 @@ def __assess_teacher(self, teacher_id): except requests.Timeout: res = self._S.get(self._urls['base_evaluateTeacher_url']['https'] + teacher_id, headers=self.headers) - bs4obj = BeautifulSoup(res.text,'html.parser') + bs4obj = BeautifulSoup(res.text,'lxml') radios = bs4obj.find_all('input', attrs={'type': 'radio'}) value = radios[0]['value'] # 默认全5星好评 data = {} @@ -132,12 +132,16 @@ def __assess_teacher(self, teacher_id): data[item_id] = asses_msg data['subjectiveCheckbox'] = '' data['subjectiveRadio'] = '' + post_action = bs4obj.find('form', {'id': 'regfrm'}) + try: + post_url = self._urls['base_url']['http'] + post_action.get('action') + except requests.Timeout: + post_url = self._urls['base_url']['https'] + post_action.get('action') try: - post_url = self._urls['base_url']['http'] + bs4obj.find('form', {'id': 'regfrm'},timeout=5).get('action') - res = self._S.post(post_url,data=data,headers = self.headers,timeout=5) + res = self._S.post(post_url, data=data, headers=self.headers, timeout=5) except requests.Timeout: - post_url = self._urls['base_url']['https'] + bs4obj.find('form', {'id': 'regfrm'}).get('action') res = self._S.post(post_url, data=data, headers=self.headers) + tmp = BeautifulSoup(res.text, 'html.parser') try: flag = tmp.find('label', attrs={'id': 'loginSuccess'}) diff --git a/core/login.py b/core/login.py index a6f08c5..9bb064a 100644 --- a/core/login.py +++ b/core/login.py @@ -42,9 +42,9 @@ def __init__(self, user_info, urls): def __keep_session(self): try: - res = self._S.get(url=self._urls['course_select_url']['http'],timeout=5) + res = self._S.get(url=self._urls['course_select_url']['http'], headers = self.headers, timeout=5) except requests.Timeout: - res = self._S.get(url=self._urls['course_select_url']['https']) + res = self._S.get(url=self._urls['course_select_url']['https'], headers = self.headers) course_select_url = re.search(r"window.location.href='(?P.*?)'", res.text).groupdict().get( "course_select_url") self._S.get(course_select_url,headers=self.headers) @@ -67,7 +67,7 @@ def login(self): json_res = res.json() if json_res["f"]: - self._S.get(res.json()["msg"]) + self._S.get(res.json()["msg"], headers=self.headers) self._logger.info("sep登录成功!") self.__keep_session() diff --git a/core/ui.py b/core/ui.py index 580d442..a14d683 100644 --- a/core/ui.py +++ b/core/ui.py @@ -24,7 +24,7 @@ ** # # # ####### # # # # # # # # # ** ** ### ### ## ## ### # # ### ##### # ### # # ** ** copyright@GentleCP ** -** version: 2.0.3 ** +** version: 2.0.4 ** ** github: https://github.com/GentleCP/UCASHelper ** ** 1:course sources download ** ** 2:wifi login **