Last active
March 5, 2020 02:15
-
-
Save geekgogo/a7c2c31524a83b7a30e8c38f32d1575c to your computer and use it in GitHub Desktop.
下载url视频
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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