抖音 根據(jù)視頻id獲取視頻詳情接口分析
本文所有教程及源碼、軟件僅為技術(shù)研究。不涉及計算機信息系統(tǒng)功能的刪除、修改、增加、干擾,更不會影響計算機信息系統(tǒng)的正常運行。不得將代碼用于非法用途,如侵立刪!
根據(jù)視頻id獲取視頻詳情接口
環(huán)境
Pyhton3.9.7
之前一直使用:https:///aweme/v1/web/aweme/detail/?aweme_id=7173874912753470732接口獲取視頻詳情,今天發(fā)現(xiàn)接口失效了,一直返回blocked,分析了一波發(fā)現(xiàn)只需要添加sv參數(shù)即可

獲取視頻詳情
? ?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'提?。簒_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):
? ? ? ?"""
? ? ? ?根據(jù)視頻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
效果


資源下載
本文僅供學(xué)習(xí)交流使用,如侵立刪!