()
| 1690 | } |
| 1691 | |
| 1692 | async function requestAlgo() { |
| 1693 | $.fingerprint = await generateFp(); |
| 1694 | const options = { |
| 1695 | "url": `https://cactus.jd.com/request_algo?g_ty=ajax`, |
| 1696 | "headers": { |
| 1697 | 'Authority': 'cactus.jd.com', |
| 1698 | 'Pragma': 'no-cache', |
| 1699 | 'Cache-Control': 'no-cache', |
| 1700 | 'Accept': 'application/json', |
| 1701 | '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', |
| 1702 | 'Content-Type': 'application/json', |
| 1703 | 'Origin': 'https://st.jingxi.com', |
| 1704 | 'Sec-Fetch-Site': 'cross-site', |
| 1705 | 'Sec-Fetch-Mode': 'cors', |
| 1706 | 'Sec-Fetch-Dest': 'empty', |
| 1707 | 'Referer': 'https://st.jingxi.com/', |
| 1708 | 'Accept-Language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7' |
| 1709 | }, |
| 1710 | 'body': JSON.stringify({ |
| 1711 | "version": "1.0", |
| 1712 | "fp": $.fingerprint, |
| 1713 | "appId": $.appId.toString(), |
| 1714 | "timestamp": Date.now(), |
| 1715 | "platform": "web", |
| 1716 | "expandParams": "" |
| 1717 | }) |
| 1718 | } |
| 1719 | return new Promise(async resolve => { |
| 1720 | $.post(options, (err, resp, data) => { |
| 1721 | try { |
| 1722 | if (err) { |
| 1723 | console.log(`${JSON.stringify(err)}`) |
| 1724 | console.log(`request_algo 签名参数API请求失败,请检查网路重试`) |
| 1725 | } else { |
| 1726 | if (data) { |
| 1727 | // console.log(data); |
| 1728 | data = JSON.parse(data); |
| 1729 | if (data['status'] === 200) { |
| 1730 | $.token = data.data.result.tk; |
| 1731 | let enCryptMethodJDString = data.data.result.algo; |
| 1732 | if (enCryptMethodJDString) $.enCryptMethodJD = new Function(`return ${enCryptMethodJDString}`)(); |
| 1733 | console.log(`获取签名参数成功!`) |
| 1734 | console.log(`fp: ${$.fingerprint}`) |
| 1735 | console.log(`token: ${$.token}`) |
| 1736 | console.log(`enCryptMethodJD: ${enCryptMethodJDString}`) |
| 1737 | } else { |
| 1738 | console.log(`fp: ${$.fingerprint}`) |
| 1739 | console.log('request_algo 签名参数API请求失败:') |
| 1740 | } |
| 1741 | } else { |
| 1742 | console.log(`京东服务器返回空数据`) |
| 1743 | } |
| 1744 | } |
| 1745 | } catch (e) { |
| 1746 | $.logErr(e, resp) |
| 1747 | } finally { |
| 1748 | resolve(); |
| 1749 | } |
no test coverage detected