【发布时间】:2019-11-25 12:26:04
【问题描述】:
我想使用 python 从 TVE(西班牙电视网站)下载视频,以便创建手语数据库。 Example:
由于有大量视频,我正在尝试使用 python 来做。
事实上,我对 Web 编程和 HTML 都一无所知。我试图检查该网站以找到指向原始视频的链接,但我认为它不起作用。我发现最相似的是这个link 我尝试使用此代码下载。
import requests
from bs4 import BeautifulSoup
'''
URL of the archive web-page which provides link to
all video lectures. It would have been tiring to
download each video manually.
In this example, we first crawl the webpage to extract
all the links and then download videos.
'''
def download_video_series(link):
'''iterate through all links in video_links
and download them one by one'''
# obtain filename by splitting url and getting
# last string
file_name = link.split('/')[-1]+'.mp4'
print
"Downloading file:%s" % file_name
# create response object
r = requests.get(link, stream=True)
# download started
with open(file_name, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024 * 1024):
if chunk:
f.write(chunk)
print( "%s downloaded!\n" % file_name)
if __name__ == "__main__":
# getting all video links
# download all videos
download_video_series('https://secure-embed.rtve.es/drmn/embed/video/5450714')
我也尝试使用wget,但它无法捕捉视频而不是text/html
有人知道吗?
【问题讨论】:
标签: python html video download request