js 的base64 加密转成Python
1 import requests 2 import execjs 3 import json 4 import base64 5 import time 6 7 url='http://webapi.cninfo.com.cn/api/sysapi/p_sysapi1007' 8 data={ 9 "tdate": "2022-04-13", 10 "market": "SZE" 11 } 12 headers={ 13 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36', 14 'mcode': base64.b64encode(str(int(time.time())).encode()).decode(), 15 'Referer': 'http://webapi.cninfo.com.cn/' 16 } 17 r = requests.post(url=url,headers=headers,data=json.dumps(data)) 18 print(r.text)
Python执行js
1 with open('spider_test.js','r',encoding='utf-8') as f: 2 result = f.read() 3 # print(result) 4 res = execjs.compile(result) 5 cc = res.call("xx")# xx 是js 的函数名
原创文章,作者:254126420,如若转载,请注明出处:https://blog.ytso.com/244578.html