抖音新版a_bogus补环境版,通过调用过程可以看到生成流程和xb差不多,通过对XMLReuqest.send方法的hook来生成a_bogus。
直接把sdk-glue.js和bdms.js复制到本地,简单补一下环境。
运行后报错throw e时,把catch下的这块删除。
再次运行无异常后,尝试模拟请求
发现并没有加载bdms中的方法,回头看调用过程。先加载sdk-glue,然后init了window._SdkGlueInit,最后加载bdms.js
把这段init也复制下来。再次运行,发现已经生成a_bogus了。
但是目前生成的不能用,缺失了环境。
通过调试可以发现一些环境没有补,下面这些参照浏览器填补。
只要这些值存在即可。
补上之后
再次运行即可获取到数据了,注意cookie中需要ttwid参数。
python调用代码
# -*- coding: utf-8 -*-
import requests
import subprocess
userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
def get_ab(url):
p = subprocess.Popen(['node', './a_bogus',url], stdout=subprocess.PIPE)
url = p.stdout.read().strip()
return url
def get_comment_list(aweme_id,ttwid):
url = f"https://www.douyin.com/aweme/v1/web/comment/list/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id={aweme_id}&cursor=0&count=20&item_type=0&insert_ids=&whale_cut_token=&cut_version=1&rcFT=&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1920&screen_height=1080&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=124.0.0.0&browser_online=true&engine_name=Blink&engine_version=124.0.0.0&os_name=Windows&os_version=10&cpu_core_num=20&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50&webid=7361743797237679616"
headers = {
"sec-ch-ua": "\"Chromium\";v=\"124\", \"Google Chrome\";v=\"124\", \"Not-A.Brand\";v=\"99\"",
"accept": "application/json, text/plain, */*",
"sec-ch-ua-mobile": "?0",
"user-agent": userAgent,
"sec-ch-ua-platform": "\"Windows\"",
"sec-fetch-site": "same-origin",
"sec-fetch-mode": "cors",
"sec-fetch-dest": "empty",
"referer": f"https://www.douyin.com/?recommend=1",
"accept-encoding": "gzip, deflate, br, zstd",
"cookie": f"ttwid={ttwid}; douyin.com; device_web_cpu_core=20; device_web_memory_size=8; architecture=amd64; home_can_add_dy_2_desktop=%220%22; dy_swidth=1920; dy_sheight=1080;",
"Priority": "u=1, i"
}
url = get_ab(url)
rest = requests.get(url,headers=headers).text
return rest
def get_user_feed(sec_user_id,ttwid):
url = f"https://www.douyin.com/aweme/v1/web/aweme/post/?device_platform=webapp&aid=6383&channel=channel_pc_web&sec_user_id={sec_user_id}&max_cursor=0&locate_item_id=7341406931216518412&locate_query=false&show_live_replay_strategy=1&need_time_list=1&time_list_query=0&whale_cut_token=&cut_version=1&count=18&publish_video_strategy_type=2&pc_client_type=1&version_code=290100&version_name=29.1.0&cookie_enabled=true&screen_width=1920&screen_height=1080&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=124.0.0.0&browser_online=true&engine_name=Blink&engine_version=124.0.0.0&os_name=Windows&os_version=10&cpu_core_num=20&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50"
headers = {
"sec-ch-ua": "\"Chromium\";v=\"124\", \"Google Chrome\";v=\"124\", \"Not-A.Brand\";v=\"99\"",
"accept": "application/json, text/plain, */*",
"sec-ch-ua-mobile": "?0",
"user-agent": userAgent,
"sec-ch-ua-platform": "\"Windows\"",
"sec-fetch-site": "same-origin",
"sec-fetch-mode": "cors",
"sec-fetch-dest": "empty",
"referer": f"https://www.douyin.com/?recommend=1",
"accept-encoding": "gzip, deflate, br, zstd",
"cookie": f"ttwid={ttwid}; douyin.com; device_web_cpu_core=20; device_web_memory_size=8; architecture=amd64; home_can_add_dy_2_desktop=%220%22; dy_swidth=1920; dy_sheight=1080;",
"Priority": "u=1, i"
}
url = get_ab(url)
rest = requests.get(url,headers=headers).text
return rest
if __name__ == '__main__':
sec_user_id = "MS4wLjABAAAAnZwyWcn9x8qLvF9sJNaO5iTSdXPQtXltUu6vR0YIAAI"
# 复制个新的ttwid测试,用请求取一个也行
ttwid = "1%7CtIiOaT1adWsSj7Ul5R2BgGQzU5QDejOd8zu1wP2Ifh4%7C1714039561%7C09bfef0cba93646268923dec34c4fa6a2f0b336d794d64916232ef3986133b49"
comment_list = get_comment_list("7341406931216518412",ttwid)
print(comment_list)
#user_feed = get_user_feed(sec_user_id,ttwid)
#print(user_feed)
Js补环境部分
【温馨提示:此处隐藏内容需要付费订阅后才能查看!】