欢迎光临散文网 会员登陆 & 注册

抖音 根据视频id获取视频详情接口分析

2023-02-28 03:04 作者:拉灯的小手  | 我要投稿

本文所有教程及源码、软件仅为技术研究。不涉及计算机信息系统功能的删除、修改、增加、干扰,更不会影响计算机信息系统的正常运行。不得将代码用于非法用途,如侵立删!

根据视频id获取视频详情接口

环境

  • win10

  • Pyhton3.9.7

之前一直使用:https:///aweme/v1/web/aweme/detail/?aweme_id=7173874912753470732接口获取视频详情,今天发现接口失效了,一直返回blocked,分析了一波发现只需要添加sv参数即可

在这里插入图片描述

获取视频详情

   def get_cookie(self):
       """
       2023.2.28 新版验证方案
       """
       count = 10
       while count:
           try:
               session = requests.session()
               h = session.get(url, verify=False, allow_redirects=False, timeout=20).headers
               x_vc_bdturing_parameters = h.get('x-vc')
               if not x_vc_bdturing_parameters:
                   count -= 1
                   logger.info(f'提取:x_vc 失败,重试!')
                   time.sleep(random.randint(3, 5))
                   continue
               detail = verify_data.get("detail")
               try:
                   msg = Verify().verify(fp, detail)
                   logger.info(msg)
               except Exception as e:
                   logger.info(f"{e}")
                   continue
               if msg.get('code') != 200:
                   logger.info(f"{msg.get('message')},重试")
                   continue
               logger.info(f"ck s_v_web_id:{fp}, {msg.get('message')}")
               s_v_web_id = f's_v_web_id={verify_data.get("fp")};'
               # self.cookie = s_v_web_id
               return s_v_web_id
           except Exception as e:              
               time.sleep(random.randint(3, 5))
               continue

       logger.error('s_v_web_id提取失败!')

   def get_user_info(self, aweme_id):
       """
       根据视频id查询视频详情
       aweme_id: 视频id
       """
       headers = {
           'accept': 'application/json, text/plain, */*',
           'cookie': self.cookie,
           "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36",
       }
       # r = requests.get(url, headers=headers)
       res = self._parse_url(url, headers=headers)
       return res

效果

请添加图片描述


在这里插入图片描述

资源下载

https://download.csdn.net/download/qq_38154948/87512210

本文仅供学习交流使用,如侵立删!


抖音 根据视频id获取视频详情接口分析的评论 (共 条)

分享到微博请遵守国家法律