Skip to content

Commit

Permalink
fix:修复部分课程解析html错误导致课程资源无法下载的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
dcp committed Oct 5, 2020
1 parent fd4add3 commit 9011826
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.2-yellowgreen)
![demo version](https://img.shields.io/badge/version-2.0.3-yellowgreen)
```angular2
*********************************************************************************
** # # ### # ### # # ### # ### ### #### **
Expand All @@ -9,7 +9,7 @@
** # # # ####### # # # # # # # # # **
** ### ### ## ## ### # # ### ##### # ### # # **
** copyright@GentleCP **
** version: 2.0.2 **
** version: 2.0.3 **
** github: https://github.com/GentleCP/UCASHelper **
** 1:course sources download **
** 2:wifi login **
Expand Down Expand Up @@ -44,7 +44,7 @@
原本只是一时兴起,为了方便写的UCAS课程网站小助手,帮助我自己进行课程资源快速同步。
没想到后面随着功能的增加,项目也变得小有规模起来,因此将其开放给全体UCAS同学,小助手的使用方式在下面有介绍,
十分简便(需要一点对`python`环境的了解,百度`python`的安装即可),如果你觉得本项目对你有所帮助的话,
希望你能帮我点个star,算是对作者的一点激励吧~
希望你能帮我点个star,算是对作者的一点激励吧~ 感谢每一个为项目点上`star`,让更多人看到这个项目的人。❤️

> 注意:由于课程网站的变动可能引发脚本失效,在失效后,我会尽量及时修复bug,并更新版本到github,
建议star项目方便接收更新消息,或者在失效时查看本项目[github链接](https://github.com/GentleCP/UCASHelper)
Expand Down Expand Up @@ -92,6 +92,8 @@
![](img/1.7.0.png)

# 2. 更新日志
- [2.0.3] 修复了部分课程因html解析不当导致的课程资源无法下载的情况,本次更新需要用到新的依赖包`lxml=4.5.2`
已安装老版本的请重新执行`pip install -r requirements.txt`
- [2.0.2] 修复了因课程网站选课系统添加头部检查导致的**课程评估,分数查询**功能的失效。
- [2.0.1] 对整体代码进行了重构,解决因课程网站`http`,`https`协议切换导致的访问出错问题,
同时更改了项目接口,方便小白和专业人士操作。以前均通过可视化`UI`界面进行操作,现在用户可选择`UI`和命令行两种模式,具体见**5.部署使用**
Expand Down Expand Up @@ -273,4 +275,3 @@ python ucashelper.py assess # 自动评教,评教内容在settings.py中设置
如果你发现了问题,并自己解决修复了,希望你能提交PR,作为贡献者帮助完善这个项目,毕竟一个人的能力是有限的,
无法面面俱到。

最后,感谢每一个为项目点上`star`,让更多人看到这个项目的人。❤️
6 changes: 4 additions & 2 deletions core/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from core.login import Loginer
from core.utils import download_file

from pprint import pprint

class Downloader(Loginer):
def __init__(self, user_info, urls, source_dir,filter_list):
super().__init__(user_info, urls)
Expand Down Expand Up @@ -86,6 +88,7 @@ def _recur_dir(self,course_info, source_url, bs4obj):
'sakai_csrf_token': csrf_token
}
res = self._S.post(source_url, data=data,headers=self.headers) # 获取文件夹下资源信息
print(res.text)
bs4obj = BeautifulSoup(res.text, 'html.parser')
self._recur_dir(course_info, source_url, bs4obj)

Expand Down Expand Up @@ -134,8 +137,7 @@ def _set_source_info(self, course_info):
bs4obj = BeautifulSoup(res.text, "html.parser")
source_url = bs4obj.find('a', {'title': '资源 - 上传、下载课件,发布文档,网址等信息'}).get("href")
res = self._S.get(source_url,headers=self.headers) # 获取课程资源页面
bs4obj = BeautifulSoup(res.text, "html.parser")

bs4obj = BeautifulSoup(res.text, "lxml")
self._recur_dir(course_info,source_url,bs4obj)


Expand Down
2 changes: 1 addition & 1 deletion core/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
** # # # ####### # # # # # # # # # **
** ### ### ## ## ### # # ### ##### # ### # # **
** copyright@GentleCP **
** version: 2.0.2 **
** version: 2.0.3 **
** github: https://github.com/GentleCP/UCASHelper **
** 1:course sources download **
** 2:wifi login **
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ click==7.1.2
docutils==0.16
idna==2.8
keyring==21.2.1
lxml==4.5.2
packaging==20.3
pkginfo==1.5.0.1
prettytable==0.7.2
Expand Down

0 comments on commit 9011826

Please sign in to comment.