Skip to content
This repository has been archived by the owner on Jan 9, 2022. It is now read-only.

网易云课堂课程,下载得到的附件压缩包(主要是代码文件)显示损坏无法打开 #17

Closed
Oshibuki opened this issue Sep 18, 2018 · 5 comments

Comments

@Oshibuki
Copy link

(错误简述)

网站:网易云课堂 MOOC

课程地址:https://mooc.study.163.com/learn/1000013001?tid=2001493000

问题描述:下载课程附件(主要是代码压缩包),显示压缩包损坏无法打开

@SigureMo
Copy link
Contributor

SigureMo commented Sep 18, 2018

全部这样吗?删掉重试呢?使用文本编辑器打开看看,里面是二进制内容还是HTML的"页面错误"内容

@SigureMo
Copy link
Contributor

SigureMo commented Sep 18, 2018

有空加个Debug用的log文件吧 @Foair 把网址等信息,都记录下来,他这个还真不好测试……

@Oshibuki
Copy link
Author

Oshibuki commented Sep 18, 2018

<script> window.open("https://www.icourse163.org/course/attachment.htm?nosKey=970E89E9A7FD4BCECA750BB6CC1E99B6-1472021484929&fileName=HttpDemoAndPPT.zip",'_self'); </script>

这个是用notepad++打开后显示的

1.3.1 HttpDemoAndPPT.zip

@SigureMo
Copy link
Contributor

喵?Σ(⊙▽⊙"a我直接用requests测试是可以下的,那个文件修改扩展名为HTML后打开也是自动跳转下载的,emmmmmmm不资到为撒能把那个页面download下来

@SigureMo
Copy link
Contributor

SigureMo commented Oct 6, 2018

问题在我的课程C++程序设计入门(下)重现
解决方法:
经测试,使用session的CANDY对课件进行下载将会重定向到一个页面后使用js进行下载,而直接使用requests则会直接下载内容,故可以直接使用requests下载或者使用参数将session注释掉,两者选择其一即可,建议使用第二种
1.

file_name = '%s %s' % (counter, file_name) # 下面是要修改的内容
with open(WORK_DIR.file(file_name), 'wb') as f:
    r = requests.get('https://www.icourse163.org/course/attachment.htm', params=params)
    f.write(r.content)
file_name = '%s %s' % (counter, file_name) # 下面是要修改的内容
CANDY.download_bin('https://www.icourse163.org/course/attachment.htm',
                                    WORK_DIR.file(file_name), params=params, cookies={'STUDY_SESS': None})

位置在study_mooc.py 167行左右

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants