forked from Toulu-debug/enen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjd_cfd_hb.ts
54 lines (44 loc) · 1.38 KB
/
jd_cfd_hb.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* export jd_cfd_hb=100
*
* 我就是看看,不抢
*/
import axios from 'axios';
import USER_AGENT, {requireConfig, requestAlgo, decrypt} from './TS_USER_AGENTS';
import * as dotenv from 'dotenv';
dotenv.config()
let cookie: string = '', cookiesArr: any, res: any = '';
!(async () => {
await requestAlgo();
cookiesArr = await requireConfig();
cookie = cookiesArr[0]
res = await api('user/ExchangeState', '_cfd_t,bizCode,dwEnv,dwType,ptag,source,strZone', {dwType: '2'})
for (let t of res.hongbao) {
console.log(t.strPrizeName, 'state:', t.dwState, 'num:', t.dwStockNum)
}
})()
interface Params {
dwType?: string,
}
function api(fn: string, stk: string, params: Params = {}) {
return new Promise(async resolve => {
let url = `https://m.jingxi.com/jxbfd/${fn}?strZone=jxbfd&bizCode=jxbfd&source=jxbfd&dwEnv=7&_cfd_t=${Date.now()}&ptag=&_ste=1&_=${Date.now()}&sceneval=2&_stk=${encodeURIComponent(stk)}`
if (Object.keys(params).length !== 0) {
let key: (keyof Params)
for (key in params) {
if (params.hasOwnProperty(key))
url += `&${key}=${params[key]}`
}
}
url += '&h5st=' + decrypt(stk, url)
let {data} = await axios.get(url, {
headers: {
'Host': 'm.jingxi.com',
'Referer': 'https://st.jingxi.com/',
'User-Agent': USER_AGENT,
'Cookie': cookie
}
})
resolve(data)
})
}