jd_h5st
v1.0.0
Published
京东H5ST算法,仅限学习交流使用
Downloads
92
Readme
yarn add jd_h5st
For example test.js
const { sign, H5stVersion } = require('jd_h5st');
const axios = require('axios');
const ua =
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090a13) XWEB/8555',
cookie =
'xxxxxxxxxxxxxxxxxxxxxxx',
pt_pin = cookie.match(/pt_pin=([^;]+)/)[1];
let data = sign({
version: H5stVersion['4.9.1'],
debug: true,
pin: pt_pin,
ua: ua,
body: {
functionId: 'pc_search_s_new',
appid: 'search-pc-java',
client: 'pc',
clientVersion: '1.0.0',
t: Date.now(),
body: {
keyword: '冰箱',
qrst: '1',
stock: '1',
pvid: 'f21a725f391945acb351132b40b9e842',
page: '2',
s: '26',
scrolling: 'y',
log_id: '1729867260644.5689',
tpl: '1_M',
isList: 0,
show_items: '',
},
'x-api-eid-token': 'jdd03EPGI6AH2UDLJPBUNQXESMHO4RBBM7DW32EEXTW76N3Y7QT6FOZVQFYWMWCABAJG7FTJBMPZ7RD3C3L7CR3NUEIENHMAAAAMSYQPQNAQAAAAACMI5UGKRLDDP7UX',
},
appId: 'xxxxxx', // appId和h5st可以二选一
h5st: 'xxxxxxxxxxxx',
});
(async () => {
const { data: temp } = await axios.request({
method: 'GET',
url: `https://api.m.jd.com/?${data.qs}`,
headers: {
'content-type': 'application/x-www-form-urlencoded',
origin: 'https://search.jd.com',
Referer: 'https://search.jd.com/',
'User-Agent': ua,
cookie,
'x-referer-page': 'https://search.jd.com/Search',
'x-rp-client': 'h5_1.0.0',
},
});
console.log(temp);
})();
enjoy it~~~