I am trying to download a video using the below code in Python.
import urllib
dwn_link = 'https://class.coursera.org/textanalytics-001/lecture/download.mp4?lecture_id=73'
file_name = 'trial_video.mp4'
urllib.retrieve(dwn_link, file_name)
But this code downloads only 382 kb and video open with an error.
Any help?
Edit: I could download all .pdf files in this page using their download links, but there seems to be some issue with video files. Video does get downloaded int my local system, but with error
In python 3,
It works for me and you can see the script at the following link
To download that video from that Coursera class, you need to be:
Once you do that, you can download the video after your HTTP client authenticates (with your username / password) and has a valid session.
You can use the library requests:
If you have access to
urllib2
, you can useurlopen
on theurl
, this would give back aresponse
object , you can doresponse.read()
toread
the data and then write it to a file.Example -
Also you need to make sure that you have authenticated to the server , if that is required for downloading the video.
I am not sure what kind of authentication
coursera.org
uses, but if its Basic HTTP Authentication (Which I highly doubt) , you can use -