通过网页分析我们找到视频的链接地址,找到后,用程序来进行爬取,只不过经测试,爬取大视频时下载比较慢,下面是代码实现
import requests
print("开始下载")
url = 'http://www.baidu.com/video/01.mp4'
r = requests.get(url, stream=True)
with open('test.mp4', "wb") as mp4:
for chunk in r.iter_content(chunk_size=1024 * 1024):
if chunk:
mp4.write(chunk)
print("下载结束")
网友评论