某#音#获取#无#水#印#视#频(无法保存的视频也可以下载)


操作步骤:

  1. 找到需要下载的视#频,点击分#享链#接
    在这里插入图片描述
  2. 将里面的链接地址提取出来,复制到下方python脚本中第12行的链接,链接应该是长这样:https://v.do#uy#in.com/dGefxad/(这个url是随手写的)
  3. 分析过程请接着后面看

Python脚本(未处理任何异常情况,本篇主要注重过程分析,有问题的小伙伴可自行分析解决)




import json
import requests


from urllib.parse import urlparse


url = 'xxxxxxxxxxxxx' # 替换这个url

def get_shared_page(url):

    if not url:
        return
    
    headers = {
        'authority': 'v.douyin.com',
        'method': 'GET',
        'path': url.replace('https://v.douyin.com',''),
        'scheme': 'https',
        'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
        'accept-encoding': 'gzip, deflate, br',
        'accept-language': 'en,zh-CN;q=0.9,zh;q=0.8',
        'sec-fetch-dest': 'document',
        'sec-fetch-mode': 'navigate',
        'sec-fetch-site': 'none',
        'upgrade-insecure-requests': '1',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36'
    }

    res = requests.get(url,headers=headers,allow_redirects=False)
    print('res is {}'.format(res.headers.get('location')))

    url = res.headers.get('location')
    u = urlparse(url)

    item_id = u.path.split('/')[-2]
    print(item_id)
    
    video_info_url = 'https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids={}'.format(item_id)
    headers = {
        'Accept': '*/*',
        'Accept-Encoding': 'gzip, deflate, br',
        'Accept-Language': 'en,zh-CN;q=0.9,zh;q=0.8',
        'Connection': 'keep-alive',
        'Host': 'www.iesdouyin.com',
        'Referer': url,
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'same-origin',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36',
        'X-Requested-With': 'XMLHttpRequest'
    }
    res = requests.get(video_info_url,headers=headers)

    json_data = json.loads(res.text)
    video_id = json_data.get('item_list')[0].get('video').get('vid')
    print('video_id is {}'.format(video_id))

    real_url = 'https://api.amemv.com/aweme/v1/play/?video_id={}&line=1&ratio=540p&media_type=4&vr_type=0&improve_bitrate=0&is_play_url=1&source=PackSourceEnum_DOUYIN_REFLOW'.format(video_id)
    
    headers = {
        'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
    }

    print('url is {}'.format(real_url))
    res = requests.get(real_url,headers=headers)
    with open('./video.mp4','wb') as f:
        f.write(res.content)


get_shared_page(url)

分析过程后面再贴出来,主要原因是审核不过

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值