一个简单、快速、可靠的 Coursera 爬取和下载工具
项目描述
去做
- 讲座(视频、字幕、幻灯片)
- 读数
- 测验
- Jupyter 笔记本
安装
需要 Python 3.x。建议将此工具安装在虚拟环境中。
$ pip install -U dl_coursera
$ dl_coursera --version
如何
-
获取cookies.txt文件
登录Coursera,然后使用浏览器扩展将 cookie 导出为cookies.txt。cookies.txt将在大约两周后过期,因此您无需如此频繁地执行此操作。
对于Chrome,您可以使用cookies.txt扩展。
对于Firefox,您可以使用Export Cookies扩展。
-
注册
导航到您要下载的课程/专业的主页,您可以在地址栏看到它的slug。注册它。
-
下载
$ dl_coursera --help usage: dl_coursera_run.py [-h] [--version] [--cookies COOKIES] --slug SLUG [--isSpec] [--n-worker {1,2,3,4,5}] [--outdir OUTDIR] --how {builtin,curl,aria2,aria2-rpc,uget,dummy} [--generate-input-file] [--aria2-rpc-url ARIA2_RPC_URL] [--aria2-rpc-secret ARIA2_RPC_SECRET] A simple, fast, and reliable Coursera crawling & downloading tool optional arguments: -h, --help show this help message and exit --version show program's version number and exit --cookies COOKIES path of the `cookies.txt` --slug SLUG slug of a course or a specializtion (with @--isSpec) --isSpec indicate that @--slug is slug of a specialization --n-worker {1,2,3,4,5} the number of threads used to crawl webpages. Default: 3 --outdir OUTDIR the directory to save files to. Default: `.' --how {builtin,curl,aria2,aria2-rpc,uget,dummy} how to download files. builtin (NOT recommonded): use the builtin downloader. curl: invoke `curl` or generate an "input file" for it (with @--generate- input-file). aria2: invoke `aria2c` or generate an "input file" for it (with @--generate-input-file). aria2-rpc (HIGHLY recommonded): add downloading tasks to aria2 through its XML-RPC interface. uget (recommonded): add downloading tasks to the uGet Download Manager --generate-input-file when @--how is curl/aria2, indicate that to generate an "input file" for that tool, rather than to invoke it --aria2-rpc-url ARIA2_RPC_URL url of the aria2 XML-RPC interface. Default: `http://localhost:6800/rpc' --aria2-rpc-secret ARIA2_RPC_SECRET authorization token of the aria2 XML-RPC interface If the command succeeds, you shall see `Done :-)`. If some UNEXPECTED errors occur, try decreasing the value of @--n-worker and/or removing the directory @--outdir. For more information, visit `https://github.com/feng-lei/dl_coursera`.# download the course, of which slug is "mathematical-thinking" # saving files to the directory "mt" # using the "built-in" downloader $ dl_coursera --cookies path/to/cookies.txt --slug mathematical-thinking --outdir mt --how builtin# download the specialization, of which slug is "algorithms" # saving files to the directory "alg" # using the "built-in" downloader $ dl_coursera --cookies path/to/cookies.txt --slug algorithms --isSpec --outdir alg --how builtin
例子
使用“内置”下载器
$ dl_coursera --cookies path/to/cookies.txt --slug mathematical-thinking --outdir mt --how builtin
使用“curl”下载器
# make sure curl (https://curl.haxx.se/download.html) is installed and in PATH
$ curl --version
“curl”下载器可以以两种不同的方式使用:调用curl,或为curl.
调用curl
$ dl_coursera --cookies path/to/cookies.txt --slug mathematical-thinking --outdir mt --how curl
生成一个输入文件curl
$ dl_coursera --cookies path/to/cookies.txt --slug mathematical-thinking --outdir mt --how curl --generate-input-file
$ curl --config mt/mathematical-thinking.download.curl_input_file.txt
使用“aria2”下载器
# make sure aria2 (https://aria2.github.io) is installed and in PATH
$ aria2c --version
“aria2”下载器可以以两种不同的方式使用:调用aria2c,或为aria2c.
调用aria2c
$ dl_coursera --cookies path/to/cookies.txt --slug mathematical-thinking --outdir mt --how aria2
生成一个输入文件aria2c
$ dl_coursera --cookies path/to/cookies.txt --slug mathematical-thinking --outdir mt --how aria2 --generate-input-file
$ aria2c --input-file mt/mathematical-thinking.download.aria2_input_file.txt
使用“aria2-rpc”下载器
# make sure aria2 (https://aria2.github.io) is installed and in PATH
$ aria2c --version
# start aria2 with its XML-RPC interface enabled
$ aria2c --enable-rpc
$ dl_coursera --cookies path/to/cookies.txt --slug mathematical-thinking --outdir mt --how aria2-rpc
强烈推荐使用像 webui -aria2这样的 aria2 GUI 。
使用“uget”下载器
# make sure uGet (https://sourceforge.net/projects/urlget/files/) is installed and in PATH
## on Windows
$ uget --version | more
## on Linux
$ uget-gtk --version
# start uGet
## on Windows
$ uget
## on Linux
$ uget-gtk &
$ dl_coursera --cookies path/to/cookies.txt --slug mathematical-thinking --outdir mt --how uget
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
dl_coursera-0.1.2.tar.gz
(20.2 kB
查看哈希)
内置分布
dl_coursera-0.1.2-py3-none-any.whl
(1.5 MB
查看哈希)
关
dl_coursera -0.1.2.tar.gz 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 9920ede32b5d7d7923e46d0788626bc1ee38262c7a40118b6da6ec93e67dddd3 |
|
| MD5 | 6dd2717b07e913a6f7a954513cc31ab9 |
|
| 布莱克2-256 | dd578fe037f40ab462d238f3d2f711f4e9f00a70095a2ba008aa01236d9dca09 |
关
dl_coursera -0.1.2-py3-none-any.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | ba0456095f392fcf394bee26c74b745c8c7e6929be967cd8e081c0ac90bd2ebb |
|
| MD5 | 741d461392a0b379370a6a7f5462afe9 |
|
| 布莱克2-256 | 862ccc5855766bb5359f182714f7f4c7bc9b9a35852f02136a4afdada6e93504 |