MCPcopy Create free account
hub / github.com/Semporia/Scripts / requestAlgo

Function requestAlgo

jd_dreamFactory.js:1572–1632  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1570}
1571
1572async function requestAlgo() {
1573 $.fingerprint = await generateFp();
1574 const options = {
1575 "url": `https://cactus.jd.com/request_algo?g_ty=ajax`,
1576 "headers": {
1577 'Authority': 'cactus.jd.com',
1578 'Pragma': 'no-cache',
1579 'Cache-Control': 'no-cache',
1580 'Accept': 'application/json',
1581 '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',
1582 'Content-Type': 'application/json',
1583 'Origin': 'https://st.jingxi.com',
1584 'Sec-Fetch-Site': 'cross-site',
1585 'Sec-Fetch-Mode': 'cors',
1586 'Sec-Fetch-Dest': 'empty',
1587 'Referer': 'https://st.jingxi.com/',
1588 'Accept-Language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7'
1589 },
1590 'body': JSON.stringify({
1591 "version": "1.0",
1592 "fp": $.fingerprint,
1593 "appId": $.appId.toString(),
1594 "timestamp": Date.now(),
1595 "platform": "web",
1596 "expandParams": ""
1597 })
1598 }
1599 new Promise(async resolve => {
1600 $.post(options, (err, resp, data) => {
1601 try {
1602 if (err) {
1603 console.log(`${JSON.stringify(err)}`)
1604 console.log(`request_algo 签名参数API请求失败,请检查网路重试`)
1605 } else {
1606 if (data) {
1607 // console.log(data);
1608 data = JSON.parse(data);
1609 if (data['status'] === 200) {
1610 $.token = data.data.result.tk;
1611 let enCryptMethodJDString = data.data.result.algo;
1612 if (enCryptMethodJDString) $.enCryptMethodJD = new Function(`return ${enCryptMethodJDString}`)();
1613 console.log(`获取签名参数成功!`)
1614 console.log(`fp: ${$.fingerprint}`)
1615 console.log(`token: ${$.token}`)
1616 console.log(`enCryptMethodJD: ${enCryptMethodJDString}`)
1617 } else {
1618 console.log(`fp: ${$.fingerprint}`)
1619 console.log('request_algo 签名参数API请求失败:')
1620 }
1621 } else {
1622 console.log(`京东服务器返回空数据`)
1623 }
1624 }
1625 } catch (e) {
1626 $.logErr(e, resp)
1627 } finally {
1628 resolve();
1629 }

Callers 1

jd_dreamFactory.jsFile · 0.70

Calls 4

generateFpFunction · 0.70
postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected