最近工作中用到了python,想起了之前看过的爬虫视频,实战一下
代码:
import requests import json base_url = 'https://www.******?url=' #修改复制目标视频url 0828 v1.0 target_url = 'https://v.douyin.com/jnEmT7C/' video_url_base = 'https://******/?video_id=' headers = { 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400', 'cookie': '__gads=ID=0613c5de4392f6a6-2268f52184cf0004:T=1640239783:RT=1640239783:S=ALNI_MYFmzURQ4PZLUsx8kWq5VTByZe82A; Hm_lvt_338f36c03fc36a54e79fbd2ebdae9589=1640239784,1640259798; Hm_lpvt_338f36c03fc36a54e79fbd2ebdae9589=1640259798' } url = base_url + target_url response = requests.get(url) load = json.loads(response.content) video_url = load.get('video_url') real_url = load.get('real_url') print(video_url) print(real_url) # 发送下载视频的网络请求 video_response = requests.get(url=video_url, headers=headers) print(video_response.status_code) if video_response.status_code == 200: # 如果请求成功 with open('0828.mp4', 'wb') as fp: fp.write(video_response.content) fp.close()
这样,就把目标视频存到了本地的0828.mp4
使用的时候只要把target_url替换成自己想要下载的抖音视频分享链接就行文章来源:https://www.toymoban.com/news/detail-409475.html
base_url和video_url_base加tobemyslf获取哦~ 文章来源地址https://www.toymoban.com/news/detail-409475.html
到了这里,关于【python】抖音无水印视频下载的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!