案例地址:财联社
找接口+加密参数
接口:
经py测试需要逆向加密参数为sign:
加密定位
定位加密位置如下:
然后分析:
a函数啥也没做:
再看p函数是什么加密:
这时候我们要进函数内部看一下:
复现逻辑+py调用
js逻辑:
py调用:
importrequestsimportexecjsimportosclassJSExecutor:def__init__(self,js_file_path):ifnot os.path.exists(js_file_path):print(f'js代码不存在:{js_file_path}')withopen(js_file_path,'r',encoding='utf-8')asf:self.js_code=f.read()# execjs.compile()将JavaScript 代码编译为一个可执行的对象 self.js_code=execjs.compile(self.js_code)defcall(self,func_name,*args):"""封装python对js代码中函数的调用:param func_name:js代码中的函数名:param args:js代码中函数所需的参数:return:js中函数运行后的结果"""returnself.js_code.call(func_name,*args)defget_data(sign,time_stamp):headers={'Referer':'https://www.cls.cn/depth?id=1003','User-Agent':'xxx',}params={'app':'CailianpressWeb','id':'1003','last_time':f'{time_stamp}','os':'web','rn':'20','sv':'8.4.6','sign':sign,}response=requests.get('https://www.cls.cn/v3/depth/list/1003',params=params,headers=headers)print(response.json())if__name__=='__main__':js_executor=JSExecutor('26.js')js_params=js_executor.call('signEnc')get_data(js_params['sign'],js_params['timestamp'])result:
小结
本文到此结束,如有问题请及时提出,加油加油