Skip to content

Instantly share code, notes, and snippets.

@geekgogo
Last active March 5, 2020 02:15
Show Gist options
  • Save geekgogo/a7c2c31524a83b7a30e8c38f32d1575c to your computer and use it in GitHub Desktop.
Save geekgogo/a7c2c31524a83b7a30e8c38f32d1575c to your computer and use it in GitHub Desktop.
下载url视频
def download_video(url, path):
try:
headers = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"
}
response = requ.get(url, headers=headers)
data = response.content
if data:
print("视频get")
# 写入收到的视频数据
with open(path, 'ab') as file:
file.write(data)
except Exception as e:
print(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment