This是我要下载的讲座的链接。单击每个链接然后下载很烦人。我想从网站下载所有mp4文件。如何实现。我已经搜索了足够长的时间,可以在这里提出问题。我已经下载了Winwget,但无法弄清楚如何下载扩展名为.mp4的文件。我对任何Windows 10或ubuntu解决方案都感到满意。
答案 0 :(得分:1)
对于某些网站,您可以使用youtube-dl
python脚本。
youtube-dl
在cmd中编写python脚本,如下所示:
C:\ Users \ user_name> youtube-dl链接
如果这是一个需要登录的网站,例如Udemy,请写
C:\Users\user_name>youtube-dl -u user@gmail.com -p password course_link
答案 1 :(得分:0)
如果可以使用Python,这是一个解决方案。它获取视频不同链接的内容,并将其存储在“ video_X.mp4”下,且X介于1到42之间:
import requests
for x in xrange(1,43):
video_url = "http://nptel.ac.in/courses/download_mp4.php?subjectId=111105035&filename=mod01lec" + str(x).zfill(2) + ".mp4"
with open('video_' + str(x).zfill(2) + '.mp4', 'wb') as handler:
handler.write(requests.get(video_url).content)
pass
答案 2 :(得分:0)
我使用以下答案 (https://stackoverflow.com/a/40553400/11786575) 来编写我的 Python 代码:
import urllib.request
### First, get a page source from Chrome inspector (press F12, select, copy and paste from "Elements"), paste the whole text here. The text should include a lot of text and also links to the mp4 video files.
filename = 'C:\\file_location...\\...\\...\\page_source_f12.txt'
### Write everything from the previous text file that includes .mp4 to a list
list_1 = []
with open(filename, "r", encoding='utf-8') as myFile:
lines = myFile.readlines()
for line in lines:
if ".mp4" in line:
a = ((str(line)).lstrip()) ### and possibly other data modification to remove "href" etc. from the text lines
print(a)
list_1.append(a)
### Use the list to write a new file including only the video links
with open('C:\\...\\video_links.txt', 'w+', encoding='utf-8') as myFile2:
for i in list_1:
myFile2.write(str(i) + "\n")
### Use urllib.request to download every video file from the links in your list
counter = 0
for url_link in list_1:
if "https" in url_link:
print(url_link)
urllib.request.urlretrieve(url_link, "video" + str(counter) + ".mp4")
print("------NOW DOWNLOADED: video" + str(counter) + ".mp4------")
counter += 1
print("*****COMPLETE******")
# If you are using vscode, the videos are downloaded to the folder where you run the code in (the fila path shown in the terminal)