Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python编程从网站下载视频_Python_Web Scraping - Fatal编程技术网

使用python编程从网站下载视频

使用python编程从网站下载视频,python,web-scraping,Python,Web Scraping,我想用python编程下载下面URL上的视频。有人能帮忙吗 谢谢下面的代码将下载您想要的文件,但它不是您想要的 import requests response = requests.get("https://projector.datacamp.com/?auto_play=play&projector_key=course_1939_153fd7068f48d10ef4d962216ccbe12b", allow_redirects=True) with o

我想用python编程下载下面URL上的视频。有人能帮忙吗


谢谢

下面的代码将下载您想要的文件,但它不是您想要的

import requests

response = requests.get("https://projector.datacamp.com/?auto_play=play&projector_key=course_1939_153fd7068f48d10ef4d962216ccbe12b", allow_redirects=True)

with open("video.html", "wb") as outfile:
    outfile.write(response.content)
这不会下载网站正在播放的视频

你要做的是找到HTML中列出的.mp4文件,你可以使用你想要的任何方法,scrapy或beautifulsoup或其他任何方法。下面的代码与实际下载的文件

import requests

response = requests.get("https://videos.datacamp.com/raw/1939_supervised_learning_w_scikit_learn/v9/1939_ch3_3.mp4", allow_redirects=True)

with open("video2.html", "wb") as outfile:
    outfile.write(response.content)

你已经试过什么了?展示一些代码。你必须展示你的代码以及你的错误。无论如何,我会回答你的问题,要完成它,首先,从页面上抓取视频URL,然后使用请求或URL库。。。下载。