Skip to content

Instantly share code, notes, and snippets.

@meoww-bot meoww-bot/v1.sh

Last active Feb 15, 2020
Embed
What would you like to do?
京东口罩库存监控,v2版本无需登录京东账号
#!/bin/bash
# 需要替换的参数:
# CHAT_ID='-1001325237796' 目标群或者频道ID
# TOKEN="BOT TOKEN" BOT的TOKEN
# Cookie 中的 THOR 可以在登录了京东账号后抓包获得
# 购买地区:
# cityId,townId,countyId 可以在"配送至" - "选择新地址",审查元素,查看对应地区的id
skuid="
100002690344
100002690350
100002690356
100002690384
100003427129
100004092111
100004092117
100004092121
100004092125
100004092143
100005151507
100005666820
100005818743
100006066047
100006248177
100006248245
100006857202
100006989522
100006992518
100006992520
100009109410
100009441994
100009442472
100009445348
100009445538
100010159728
100010258482
100010439846
100010638508
100010908190
100011293928
100011293950
10652011044
15941729623
1612617210
1612617211
1612617212
22753397779
35371843916
35502042992
35502042995
45801275120
45801275121
48385661121
48385661122
48392511532
51137726179
55521546969
58931474386
59959871347
65420816726
65420816727
65425102594
65425102595
65425102596
65425149164
65425149165
65429694202
65437208345
65444576693
7043722
7257333
7263128
7498167
7950392
"
want='有货'
CHAT_ID='-1001325237796'
TOKEN="BOT TOKEN"
for id in $skuid
do
#echo $i
res=$(curl -s 'https://trade.jd.com/api/v1/batch/stock' -H 'authority: trade.jd.com' -H 'accept: application/json, text/javascript, */*; q=0.01' -H 'origin: https://trade.jd.com' -H 'x-requested-with: XMLHttpRequest' -H 'content-type: application/json; charset=UTF-8' -H 'referer: https://trade.jd.com/shopping/order/getOrderInfo.action' -H 'accept-language: zh-CN,zh;q=0.9,en;q=0.8' -H 'cookie: thor=<THOR VALUE>' --data-binary '{"skuNumList":[{"skuId":'$id',"num":"1"}],"areaRequest":{"provinceId":"22","cityId":"<cityId>","countyId":"<countyId>","townId":"<townId>"}}' --compressed)
if grep -q "$want" <<< "$res"; then
TEXT="SKUID: $id\nSTOCK: $want Link: https://item.jd.com/$id.html"
echo -e $TEXT | curl -G --data-urlencode text@- "https://api.telegram.org/bot$TOKEN/sendMessage?chat_id=$CHAT_ID"
fi
echo "SKUID: $id Result: $res Link: https://item.jd.com/$id.html"
sleep 1
done
#!/bin/bash
# 需要替换的参数:
# CHAT_ID='-1001325237796' 目标群或者频道ID
# TOKEN="BOT TOKEN" BOT的TOKEN
# 购买地区:
# cityId,townId,countyId 可以在"配送至" - "选择新地址",审查元素,查看对应地区的id
skuid="
100002690344
100002690350
100002690356
100002690384
100003427129
100004092111
100004092117
100004092121
100004092125
100004092143
100005151507
100005666820
100005818743
100006066047
100006248177
100006248245
100006857202
100006989522
100006992518
100006992520
100009109410
100009441994
100009442472
100009445348
100009445538
100010159728
100010258482
100010439846
100010638508
100010908190
100011293928
100011293950
10652011044
1336984
15941729623
1612617210
1612617211
1612617212
22753397779
35371843916
35502042992
35502042995
35668608578
35669407159
45185106048
45712329352
45801275120
45801275121
48385661121
48385661122
48392511532
51137726179
54080043790
54080043791
54080043792
55521546969
58931474386
59959871347
6023863
61202994740
62408717969
62408717970
65420816726
65420816727
65425102594
65425102595
65425102596
65425149164
65425149165
65429694202
65437208345
65444576693
7043722
7257333
7263128
7498167
7950392
"
CHAT_ID='-1001325237796'
TOKEN="BOT TOKEN"
# 配送至 审查元素 获得
provinceId='' #
cityId='' #
townId='' #
countyId='' #
for id in $skuid
do
res=$(curl -s "https://c0.3.cn/stocks?type=getstocks&skuIds=$id&area=${provinceId}_${cityId}_${townId}_${countyId}" -H 'Connection: keep-alive' -H 'Accept: */*' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8')
stockstate=$(echo $res | jq -r '.[]["StockState"]')
skustate=$(echo $res | jq -r '.[]["skuState"]')
if [ "$stockstate" == 33 ] && [ "$skustate" == 1 ] ; then
TEXT="SKUID: $id\nSTOCK: 有货 \nLink: https://item.jd.com/$id.html"
echo -e $TEXT | curl -G --data-urlencode text@- "https://api.telegram.org/bot$TOKEN/sendMessage?chat_id=$CHAT_ID"
fi
echo "SKUID: $id StockState(33): $stockstate skuState(1): $skustate Link: https://item.jd.com/$id.html"
sleep 1
done
# StockState: 33 有货 34 无货
# skuState: 1 上架 0 下架
# example
# 上架了无货
# {"1612617211":{"StockState":34,"freshEdi":null,"ab":"-1","ac":"-1","ad":"-1","ae":"-1","skuState":1,"PopType":0,"af":"-1","ag":"-1","sidDely":"163","channel":1,"StockStateName":"无货","rid":"110008301","m":"0","sid":"163","rfg":0,"dcId":"6","ArrivalDate":"","v":"0","IsPurchase":false,"rn":-1,"eb":"99","ec":"-1"}}
# 上架了有货
# {"65444576694":{"StockState":33,"freshEdi":null,"ab":"-1","ac":"-1","ad":"-1","ae":"-1","skuState":1,"PopType":0,"af":"-1","ag":"-1","sidDely":"-1","channel":1,"StockStateName":"现货","rid":null,"m":"0","sid":"-1","rfg":0,"dcId":"-1","ArrivalDate":"","v":"0","IsPurchase":false,"rn":-1,"eb":"99","ec":"-1"}}
# 下架有货
# {"65444576693":{"StockState":33,"freshEdi":null,"ab":"-1","ac":"-1","ad":"-1","ae":"-1","skuState":0,"PopType":0,"af":"-1","ag":"-1","sidDely":"-1","channel":1,"StockStateName":"现货","rid":null,"m":"0","sid":"-1","rfg":0,"dcId":"-1","ArrivalDate":"","v":"0","IsPurchase":false,"rn":3,"eb":"99","ec":"-1"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.