()
| 458 | } |
| 459 | |
| 460 | async function requestAlgo() { |
| 461 | $.fingerprint = await generateFp(); |
| 462 | const options = { |
| 463 | "url": `https://cactus.jd.com/request_algo?g_ty=ajax`, |
| 464 | "headers": { |
| 465 | 'Authority': 'cactus.jd.com', |
| 466 | 'Pragma': 'no-cache', |
| 467 | 'Cache-Control': 'no-cache', |
| 468 | 'Accept': 'application/json', |
| 469 | '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', |
| 470 | 'Content-Type': 'application/json', |
| 471 | 'Origin': 'https://st.jingxi.com', |
| 472 | 'Sec-Fetch-Site': 'cross-site', |
| 473 | 'Sec-Fetch-Mode': 'cors', |
| 474 | 'Sec-Fetch-Dest': 'empty', |
| 475 | 'Referer': 'https://st.jingxi.com/', |
| 476 | 'Accept-Language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7' |
| 477 | }, |
| 478 | 'body': JSON.stringify({ |
| 479 | "version": "1.0", |
| 480 | "fp": $.fingerprint, |
| 481 | "appId": $.appId.toString(), |
| 482 | "timestamp": Date.now(), |
| 483 | "platform": "web", |
| 484 | "expandParams": "" |
| 485 | }) |
| 486 | } |
| 487 | new Promise(async resolve => { |
| 488 | $.post(options, (err, resp, data) => { |
| 489 | try { |
| 490 | if (err) { |
| 491 | console.log(`${JSON.stringify(err)}`) |
| 492 | console.log(`request_algo 签名参数API请求失败,请检查网路重试`) |
| 493 | } else { |
| 494 | if (data) { |
| 495 | // console.log(data); |
| 496 | data = JSON.parse(data); |
| 497 | if (data['status'] === 200) { |
| 498 | $.token = data.data.result.tk; |
| 499 | let enCryptMethodJDString = data.data.result.algo; |
| 500 | if (enCryptMethodJDString) $.enCryptMethodJD = new Function(`return ${enCryptMethodJDString}`)(); |
| 501 | console.log(`获取签名参数成功!`) |
| 502 | console.log(`fp: ${$.fingerprint}`) |
| 503 | console.log(`token: ${$.token}`) |
| 504 | console.log(`enCryptMethodJD: ${enCryptMethodJDString}`) |
| 505 | } else { |
| 506 | console.log(`fp: ${$.fingerprint}`) |
| 507 | console.log('request_algo 签名参数API请求失败:') |
| 508 | } |
| 509 | } else { |
| 510 | console.log(`京东服务器返回空数据`) |
| 511 | } |
| 512 | } |
| 513 | } catch (e) { |
| 514 | $.logErr(e, resp) |
| 515 | } finally { |
| 516 | resolve(); |
| 517 | } |
no test coverage detected