This program allows you to download courses from Coursera.
Program can download video lessons, accompanying materials(mp4 in different resolutions, subtitles), quiz assignments, and other types of lessons in the form of screenshots and PDF files.
There are three commands: login, get-course-data, and download-course. If you want to download a course, you must follow these instructions:
- Sign in to your account using the
logincommand. - Download information about the course using the
get-course-datacommand into a JSON file. - Finally, apply the
download-coursecommand to your JSON file.
-
pip install -r requirements.txt
This command will install the required libraries. -
python main.py login --email <EMAIL> --password <PASSWORD>
This command saves your cookies into ./cookies/last-saved.pkl. Additionally, you can use the parameter--file-name <FILENAME>.pklto save your cookies to ./cookies/<FILENAME>.pkl. -
python main.py get-course-data -u <url>
As a result of this command, all data about the course will be downloaded to ./download/<COURSE_NAME>.json.
Usually,<url>looks likehttps://www.coursera.org/learn/<COURSE_NAME>/home/week/1. You don't need to apply this command for all weeks. The algorithm looks at the first page, calculates the number of weeks, and parses all courses.
If you use--file-namein thelogincommand, then you can add--cookies <FILENAME>.pklto select a different session. -
python main.py download-course -p <path_to_data>.jsonAfter applying this command, all course data will be downloaded to ./downloads/<COURSE_NAME>/.
Like previous section, there you also can use--cookiesto select appropriate session.
-
Sometimes Coursera changes its website code, so the parser may break until I update the web element paths.
-
If you see an exception like this "AssertionError: Unrecognized lesson type Peer-graded Assignment" (where Peer-graded Assignment may be replaced by another lesson type), simply set
DEBUG = Falsein defines.py. -
You can only use the English version of the website. To change the website language, go to Settings.