This commit is contained in:
Faker 2022-06-13 10:54:00 +08:00
parent ac1314af7c
commit fe71d16d00
9 changed files with 1592 additions and 15 deletions

265
jd_618lottery.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -66,6 +66,7 @@ const JD_API_HOST = 'https://api.m.jd.com/';
continue
}
await jdBeanHome();
await $.wait(parseInt(Math.random() * 5000 + 8000, 10))
}
}
// for (let i = 0; i < cookiesArr.length; i++) {
@ -111,11 +112,6 @@ const JD_API_HOST = 'https://api.m.jd.com/';
// }
// }
// }
if($.outFlag) {
let msg = '好像IP黑了换个IP试试吧'
$.msg($.name, ``, `${msg}`);
if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`);
}
})()
.catch((e) => {
$.log('', `${$.name}, 失败! 原因: ${e}!`, '')
@ -132,11 +128,11 @@ async function jdBeanHome() {
// await $.wait(1000)
// if ($.doneState) break
// }
do {
$.outFlag = false
do {
await doTask2()
if ($.outFlag) return
await $.wait(3000)
if ($.outFlag) break
await $.wait(5000)
} while (!$.doneState)
await $.wait(1000)
await award("feeds")
@ -150,16 +146,16 @@ async function jdBeanHome() {
//await $.wait(1000)
await beanTaskList(1)
await $.wait(1000)
await $.wait(2000)
await queryCouponInfo()
$.doneState = false
let num = 0
do {
await $.wait(2000)
await $.wait(3000)
await beanTaskList(2)
num++
} while (!$.doneState && num < 5)
await $.wait(2000)
await $.wait(3000)
if ($.doneState) await beanTaskList(3)
await showMsg();

268
jd_beans_7days.py Normal file
View File

@ -0,0 +1,268 @@
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
# Modify : 2022/5/13
# 京豆近7天输出表格统计
# 用不着每天跑,定时自行设置吧配合desi可指定账号
# https://raw.githubusercontent.com/6dylan6/jdpro/main/jd_beans_7days.py
'''
new Env('豆子7天统计');
1 8 13 5 * jd_beans_7days.py
'''
import requests
import datetime
import os,re,sys,json,time
from urllib.parse import unquote
from datetime import timedelta
from datetime import timezone
try:
from prettytable import PrettyTable
except:
os.system('pip3 install prettytable &> /dev/null')
from prettytable import PrettyTable
SHA_TZ = timezone(
timedelta(hours=8),
name='Asia/Shanghai',
)
requests.adapters.DEFAULT_RETRIES = 5
session = requests.session()
session.keep_alive = False
url = "https://api.m.jd.com/api"
def gen_body(page):
body = {
"beginDate": datetime.datetime.utcnow().replace(tzinfo=timezone.utc).astimezone(SHA_TZ).strftime("%Y-%m-%d %H:%M:%S"),
"endDate": datetime.datetime.utcnow().replace(tzinfo=timezone.utc).astimezone(SHA_TZ).strftime("%Y-%m-%d %H:%M:%S"),
"pageNo": page,
"pageSize": 20,
}
return body
def printf(text):
print(text)
sys.stdout.flush()
def column_pad(*columns):
max_len = max([len(x) for x in columns])
for y in columns:
y.extend(['NaN']*(max_len-len(y)))
class getJDCookie(object):
# 获取cookie
def getCookie(self):
global cookies
cookies = []
try:
if "JD_COOKIE" in os.environ:
if len(os.environ["JD_COOKIE"]) > 10:
cookies = os.environ["JD_COOKIE"]
printf("\n当前从环境变量获取CK\n")
return
except Exception as e:
printf(f"【getCookie Error】{e}")
# 检测cookie格式是否正确
def getUserInfo(self, ck, pinName, userNum):
url = 'https://me-api.jd.com/user_new/info/GetJDUserInfoUnion?orgFlag=JD_PinGou_New&callSource=mainorder&channel=4&isHomewhite=0&sceneval=2&sceneval=2&callback='
headers = {
'Cookie': ck,
'Accept': '*/*',
'Connection': 'close',
'Referer': 'https://home.m.jd.com/myJd/home.action',
'Accept-Encoding': 'gzip, deflate, br',
'Host': 'me-api.jd.com',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.1',
'Accept-Language': 'zh-cn'
}
try:
if sys.platform == 'ios':
resp = requests.get(url=url, verify=False, headers=headers, timeout=60).json()
else:
resp = requests.get(url=url, headers=headers, timeout=60).json()
if resp['retcode'] == "0":
nickname = resp['data']['userInfo']['baseInfo']['nickname']
if not nickname:
nickname = resp['data']['userInfo']['baseInfo']['curPin']
return ck, nickname
else:
context = f"账号{userNum}{pinName}】Cookie 已失效!请重新获取\n"
printf(context)
return ck, False
except Exception:
context = f"账号{userNum}{pinName}】Cookie 已失效!请重新获取\n"
printf(context)
return ck, False
def iscookie(self):
"""
:return: cookiesList,userNameList,pinNameList
"""
cookiesList = []
userNameList = []
pinNameList = []
if 'pt_key=' in cookies and 'pt_pin=' in cookies:
r = re.compile(r"pt_key=.*?pt_pin=.*?;", re.M | re.S | re.I)
result = r.findall(cookies)
if len(result) >= 1:
printf("您有{}个账号".format(len(result)))
u = 1
for i in result:
r = re.compile(r"pt_pin=(.*?);")
pinName = r.findall(i)
pinName = unquote(pinName[0])
# 获取账号名
ck, nickname = self.getUserInfo(i, pinName, u)
if nickname:
cookiesList.append(ck)
userNameList.append(nickname)
pinNameList.append(pinName)
else:
u += 1
continue
u += 1
if len(cookiesList) > 0 and len(userNameList) > 0:
return cookiesList, userNameList, pinNameList
else:
printf("没有可用CK已退出\n")
exit(3)
else:
printf("CK格式错误...本次运行退出\n")
exit(4)
else:
printf("CK格式错误或无CK...请检查\n")
exit(4)
getCk = getJDCookie()
getCk.getCookie()
def gen_params(page):
body = gen_body(page)
params = {
"functionId": "jposTradeQuery",
"appid": "swat_miniprogram",
"client": "tjj_m",
"sdkName": "orderDetail",
"sdkVersion": "1.0.0",
"clientVersion": "3.1.3",
"timestamp": int(round(time.time() * 1000)),
"body": json.dumps(body)
}
return params
def creat_bean_count(date, beansin, beansout, beanstotal):
tb = PrettyTable()
tb.add_column('DATE', date)
tb.add_column('BEANSIN', beansin)
tb.add_column('BEANSOUT', beansout)
tb.add_column('TOTAL', beanstotal)
printf(tb)
def get_beans_7days(ck):
try:
day_7 = True
page = 0
headers = {
"Host": "api.m.jd.com",
"Connection": "keep-alive",
"charset": "utf-8",
"User-Agent": "Mozilla/5.0 (Linux; Android 10; MI 9 Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.62 XWEB/2797 MMWEBSDK/201201 Mobile Safari/537.36 MMWEBID/7986 MicroMessenger/8.0.1840(0x2800003B) Process/appbrand4 WeChat/arm64 Weixin NetType/4G Language/zh_CN ABI/arm64 MiniProgramEnv/android",
"Content-Type": "application/x-www-form-urlencoded;",
"Accept-Encoding": "gzip, compress, deflate, br",
"Cookie": ck,
"Referer": "https://servicewechat.com/wxa5bf5ee667d91626/141/page-frame.html",
}
days = []
for i in range(0, 7):
days.append((datetime.date.today() - datetime.timedelta(days=i)).strftime("%Y-%m-%d"))
beans_in = {key: 0 for key in days}
beans_out = {key: 0 for key in days}
while day_7:
page = page + 1
resp = session.get(url, params=gen_params(page), headers=headers, timeout=100).text
res = json.loads(resp)
if res['resultCode'] == 0 and res['data']['list'] != []:
for i in res['data']['list']:
for date in days:
if str(date) in i['createDate'] and i['amount'] > 0:
beans_in[str(date)] = beans_in[str(date)] + i['amount']
break
elif str(date) in i['createDate'] and i['amount'] < 0:
beans_out[str(date)] = beans_out[str(date)] + i['amount']
break
if i['createDate'].split(' ')[0] not in str(days):
day_7 = False
else:
print("未获取到数据,原因未知!!\n")
return {'code': 400, 'data': res}
return {'code': 200, 'data': [beans_in, beans_out, days]}
except Exception as e:
print(str(e))
return {'code': 400, 'data': str(e)}
def get_total_beans(ck):
try:
headers = {
"Host": "wxapp.m.jd.com",
"Connection": "keep-alive",
"charset": "utf-8",
"User-Agent": "Mozilla/5.0 (Linux; Android 10; MI 9 Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.62 XWEB/2797 MMWEBSDK/201201 Mobile Safari/537.36 MMWEBID/7986 MicroMessenger/8.0.1840(0x2800003B) Process/appbrand4 WeChat/arm64 Weixin NetType/4G Language/zh_CN ABI/arm64 MiniProgramEnv/android",
"Content-Type": "application/x-www-form-urlencoded;",
"Accept-Encoding": "gzip, compress, deflate, br",
"Cookie": ck,
}
jurl = "https://wxapp.m.jd.com/kwxhome/myJd/home.json"
resp = session.get(jurl, headers=headers, timeout=100).text
res = json.loads(resp)
return res['user']['jingBean']
except Exception as e:
printf(str(e))
def get_bean_data(i,ck):
try:
if ck:
#ck = cookies[i-1]
beans_res = get_beans_7days(ck)
beantotal = get_total_beans(ck)
if beans_res['code'] != 200:
return beans_res
else:
beans_in, beans_out = [], []
beanstotal = [int(beantotal), ]
for i in beans_res['data'][0]:
beantotal = int(beantotal) - int(beans_res['data'][0][i]) - int(beans_res['data'][1][i])
beans_in.append(int(beans_res['data'][0][i]))
beans_out.append(int(str(beans_res['data'][1][i]).replace('-', '')))
beanstotal.append(beantotal)
return {'code': 200, 'data': [beans_in[::-1], beans_out[::-1], beanstotal[::-1], beans_res['data'][2][::-1]]}
except Exception as e:
print(str(e))
def query():
try:
global cookiesList, userNameList, pinNameList, ckNum, beanCount, userCount
cookiesList, userNameList, pinNameList = getCk.iscookie()
for i,ck,user,pin in zip(range(1,len(cookiesList)+1),cookiesList,userNameList,pinNameList):
printf(f"\n****** [账号{i}]-{user} ******")
res=get_bean_data(i,ck)
if res['code'] != 200:
printf(res['data'])
continue
if res['data'][2][1:] != []:
creat_bean_count(res['data'][3], res['data'][0], res['data'][1], res['data'][2][1:])
time.sleep(2)
except Exception as e:
printf(str(e))
if __name__ == "__main__":
query()

View File

@ -27,7 +27,7 @@ let shopname=''
const token = [
"FD7F0E88F2555A9A7254AA00D6DDA1F6",
"4BE1B58FE1360409A5967CAD1127B5A8",
"E9885E4C06000433BBB4221A04D44C36",
"DBD58C7DDEB7D5EE3E99C164755C0BEE",
"3B27B2B9E70249C339D66F27B7E133F0",
"70E81DD8CF06D043FE1FD2DB60B59987",
"572B5331C2303ABFF034700EDDFE2B41",
@ -38,13 +38,15 @@ const token = [
"E29627AF30D59CF7FE7B01C63BD9A975",
"5B43A702C5CC14509CD8FB6F725326FC",
"22E454E7DA34CBA96DFAB150C2882193",
"EBC1F95B42459D9F27E2025E11E1F7C6",
"67A72DF4DCE945E561051B08A48594A9",
"05FE7C8117A8CF6FA8BAD56C6E776CD7",
"7C54AE28BAEDCBB8C927768AE71CA0EF",
"809569E3816B2C76210BFF8DB3F2766E",
"3B864BF96848A44E170A26D2791E0AE3",
"0CB602BF5179A3A4670621F3F83C494E",
"174F67A03DD7EF31096C0F35EFF45702",
"7D7E23BB728C9D7425C776BDC8943D10",
"9F75D813CBE3D1F9B146F002FEA4FF2D",
"CCB11192ED79F4AF11EABBD732B26874",
"85B78F013645D1EC53D5F3974528654A"
]

13
jd_drawCenter.js Normal file

File diff suppressed because one or more lines are too long

546
jd_lzdz1_customized6101.js Normal file

File diff suppressed because one or more lines are too long

477
jd_mpdz-car.js Normal file

File diff suppressed because one or more lines are too long

10
jd_mpdz.js Executable file

File diff suppressed because one or more lines are too long

View File

@ -196,7 +196,7 @@ async function jstoken() {
};
const dom = new JSDOM(`<body>
<script src="https:////static.360buyimg.com/siteppStatic/script/mescroll/map.js"></script>
<script src="https://storage.360buyimg.com/webcontainer/js_security_v3.js"></script>
<script src="https://storage.360buyimg.com/webcontainer/js_security_v3_0.1.0.js"></script>
<script src="https://static.360buyimg.com/siteppStatic/script/utils.js"></script>
<script src="https://js-nocaptcha.jd.com/statics/js/main.min.js"></script>
</body>`, options);