()
| 225 | } |
| 226 | |
| 227 | async function requestAlgo() { |
| 228 | $.fingerprint = await generateFp(); |
| 229 | const options = { |
| 230 | "url": `https://cactus.jd.com/request_algo?g_ty=ajax`, |
| 231 | "headers": { |
| 232 | 'Authority': 'cactus.jd.com', |
| 233 | 'Pragma': 'no-cache', |
| 234 | 'Cache-Control': 'no-cache', |
| 235 | 'Accept': 'application/json', |
| 236 | 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1', |
| 237 | 'Content-Type': 'application/json', |
| 238 | 'Origin': 'https://st.jingxi.com', |
| 239 | 'Sec-Fetch-Site': 'cross-site', |
| 240 | 'Sec-Fetch-Mode': 'cors', |
| 241 | 'Sec-Fetch-Dest': 'empty', |
| 242 | 'Referer': 'https://st.jingxi.com/', |
| 243 | 'Accept-Language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7' |
| 244 | }, |
| 245 | 'body': JSON.stringify({ |
| 246 | "version": "1.0", |
| 247 | "fp": $.fingerprint, |
| 248 | "appId": $.appId.toString(), |
| 249 | "timestamp": Date.now(), |
| 250 | "platform": "web", |
| 251 | "expandParams": "" |
| 252 | }) |
| 253 | } |
| 254 | new Promise(async resolve => { |
| 255 | $.post(options, (err, resp, data) => { |
| 256 | try { |
| 257 | if (err) { |
| 258 | console.log(`${JSON.stringify(err)}`) |
| 259 | console.log(`request_algo 签名参数API请求失败,请检查网路重试`) |
| 260 | } else { |
| 261 | if (data) { |
| 262 | // console.log(data); |
| 263 | data = JSON.parse(data); |
| 264 | if (data['status'] === 200) { |
| 265 | $.token = data.data.result.tk; |
| 266 | let enCryptMethodJDString = data.data.result.algo; |
| 267 | if (enCryptMethodJDString) $.enCryptMethodJD = new Function(`return ${enCryptMethodJDString}`)(); |
| 268 | console.log(`获取签名参数成功!`) |
| 269 | console.log(`fp: ${$.fingerprint}`) |
| 270 | console.log(`token: ${$.token}`) |
| 271 | console.log(`enCryptMethodJD: ${enCryptMethodJDString}`) |
| 272 | } else { |
| 273 | console.log(`fp: ${$.fingerprint}`) |
| 274 | console.log('request_algo 签名参数API请求失败:') |
| 275 | } |
| 276 | } else { |
| 277 | console.log(`京东服务器返回空数据`) |
| 278 | } |
| 279 | } |
| 280 | } catch (e) { |
| 281 | $.logErr(e, resp) |
| 282 | } finally { |
| 283 | resolve(); |
| 284 | } |
no test coverage detected