import requests
import execjs
def get_xb_fun1(query_data):
# 源自 https://www.bilibili.com/read/cv24184072/?jump_opus=1
postdata = {
'query': query_data,
'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0'
}
url = "https://www.liaochanglin.top/douyin/x-bogus"
response = requests.post(url=url, data=postdata)
result = response.json().get('X-Bogus')
return result
if __name__ == '__main__':
max_cursor = 0
arg1 = ('device_platform=webapp&aid=6383&channel=channel_pc_web'
'&sec_user_id=MS4wLjABAAAAqsOmrExIsJbZ2b0QLzytzAhAFbJUROH72_yVYM7Zq8E'
f'&max_cursor={max_cursor}'
'&locate_item_id=7273024102460362047&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=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=118.0.0.0&browser_online=true'
'&engine_name=Blink&engine_version=118.0.0.0&os_name=Windows&os_version=10'
'&cpu_core_num=6&device_memory=8&platform=PC&downlink=10&effective_type=4g'
'&round_trip_time=0&webid=7206570248416773684'
'&msToken=9AJahOs26313LnWH_inVtw79X2HztOIymCFdbPccKGt5yqqJhbJKDenFVr5Vr2b-yFpQhUdyKm8gXB-WZDZUKBhTomG-y_fC60RV0wt8UZRWAFLMDG6e5tLuf-gVcvk=')
get_xb_fun1(arg1)
此方法是调用B站一个大佬部署的一个API接口传入参数后会回传X-Bogus参数,得到后可直接使用
代码中参数获取方法:
arg1:如下图中两个红线之间的所有字符
max_cursor:如下图红框标注,进行翻页时要用到,第一页默认是0,第二页的值来源于第一页的响应结果
user-agent:请求头里面找