import requests
video_url = 'https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0300f0c0000blvmurlqukgb6o87iq1g&line=0'
"""
headers中的设置是固定搭配,将python代码伪造成是谷歌浏览器的访问。
"""
response = requests.get(
url=video_url,
headers={
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36'
}
)
with open('xxxx.mp4', 'wb') as f:
for chunk in response.iter_content():
f.write(chunk)