mirror of
https://github.com/shufflewzc/faker2.git
synced 2025-04-23 02:48:44 +08:00
expired
This commit is contained in:
parent
8d2b54230f
commit
8e960fdcb6
48
jdCookie.py
48
jdCookie.py
@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Time : 2022/7/6 23:00
|
||||
# @Author : HarbourJ
|
||||
# @TG : https://t.me/HarbourToulu
|
||||
# @File : jdCookie.py
|
||||
|
||||
import os
|
||||
import time
|
||||
from functools import partial
|
||||
print = partial(print, flush=True)
|
||||
|
||||
|
||||
def get_cookies():
|
||||
CookieJDs = []
|
||||
if os.environ.get("JD_COOKIE"):
|
||||
print("已获取并使用Env环境 Cookie")
|
||||
if '&' in os.environ["JD_COOKIE"]:
|
||||
CookieJDs = os.environ["JD_COOKIE"].split('&')
|
||||
elif '\n' in os.environ["JD_COOKIE"]:
|
||||
CookieJDs = os.environ["JD_COOKIE"].split('\n')
|
||||
else:
|
||||
CookieJDs = [os.environ["JD_COOKIE"]]
|
||||
# return CookieJDs
|
||||
else:
|
||||
if os.path.exists("JD_COOKIE.txt"):
|
||||
with open("JD_COOKIE.txt", 'r') as f:
|
||||
JD_COOKIEs = f.read().strip()
|
||||
if JD_COOKIEs:
|
||||
if '&' in JD_COOKIEs:
|
||||
CookieJDs = JD_COOKIEs.split('&')
|
||||
elif '\n' in JD_COOKIEs:
|
||||
CookieJDs = JD_COOKIEs.split('\n')
|
||||
else:
|
||||
CookieJDs = [JD_COOKIEs]
|
||||
CookieJDs = sorted(set(CookieJDs), key=CookieJDs.index)
|
||||
# return CookieJDs
|
||||
else:
|
||||
print("未获取到正确✅格式的京东账号Cookie")
|
||||
return
|
||||
|
||||
print(f"====================共{len(CookieJDs)}个京东账号Cookie=========\n")
|
||||
print(f"==================脚本执行- 北京时间(UTC+8):{time.strftime('%Y/%m/%d %H:%M:%S', time.localtime())}=====================\n")
|
||||
return CookieJDs
|
||||
|
||||
# if __name__ == "__main__":
|
||||
# get_cookies()
|
||||
# print(os.environ.get("JD_COOKIE"))
|
196
jd_dpcj.py
196
jd_dpcj.py
@ -1,196 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
File: jd_dpcj.py(店铺抽奖-JK)
|
||||
Author: HarbourJ
|
||||
Date: 2022/10/15 23:00
|
||||
TG: https://t.me/HarbourToulu
|
||||
TgChat: https://t.me/HarbourChat
|
||||
cron: 1 1 1 1 1 1
|
||||
new Env('店铺抽奖-JK');
|
||||
ActivityEntry:https://shop.m.jd.com/shop/lottery?shopId=xxxxx&venderId=xxxxx
|
||||
Description: 变量:export DPCJID="shopId1&shopId2" #变量为店铺🆔
|
||||
"""
|
||||
|
||||
import requests, time, re, os, sys, json
|
||||
from datetime import datetime
|
||||
from sendNotify import *
|
||||
from urllib.parse import quote_plus, unquote_plus
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
from functools import partial
|
||||
print = partial(print, flush=True)
|
||||
try:
|
||||
from jd_sign import *
|
||||
except ImportError as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
print("请先运行Faker库依赖一键安装脚本(jd_check_dependent.py),安装jd_sign.so依赖")
|
||||
sys.exit()
|
||||
try:
|
||||
from jdCookie import get_cookies
|
||||
getCk = get_cookies()
|
||||
except:
|
||||
print("请先下载依赖脚本,\n下载链接:https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
|
||||
sys.exit(3)
|
||||
|
||||
dpcj = os.environ.get("DPCJID") if os.environ.get("DPCJID") else ""
|
||||
|
||||
if not dpcj:
|
||||
print("⚠️未发现有效店铺签到活动变量DPCJID,退出程序!")
|
||||
sys.exit()
|
||||
|
||||
def check(ua, ck):
|
||||
try:
|
||||
url = 'https://me-api.jd.com/user_new/info/GetJDUserInfoUnion'
|
||||
header = {
|
||||
"Host": "me-api.jd.com",
|
||||
"Accept": "*/*",
|
||||
"Connection": "keep-alive",
|
||||
"Cookie": ck,
|
||||
"User-Agent": ua,
|
||||
"Accept-Language": "zh-cn",
|
||||
"Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&",
|
||||
"Accept-Encoding": "gzip, deflate",
|
||||
}
|
||||
result = requests.get(url=url, headers=header, timeout=None).text
|
||||
codestate = json.loads(result)
|
||||
if codestate['retcode'] == '1001':
|
||||
msg = "⚠️当前ck已失效,请检查"
|
||||
return {'code': 1001, 'data': msg}
|
||||
elif codestate['retcode'] == '0' and 'userInfo' in codestate['data']:
|
||||
nickName = codestate['data']['userInfo']['baseInfo']['nickname']
|
||||
return {'code': 200, 'name': nickName, 'ck': ck}
|
||||
except Exception as e:
|
||||
return {'code': 0, 'data': e}
|
||||
|
||||
def get_time():
|
||||
time_now = round(time.time() * 1000)
|
||||
return time_now
|
||||
|
||||
def getSignInfo(ua, ck, shopId, venderId):
|
||||
url = f"https://api.m.jd.com/client.action?functionId=whx_getSignInfo&body=%7B%22shopId%22%3A%22{shopId}%22%2C%22venderId%22%3A%22{venderId}%22%2C%22source%22%3A%22m-shop%22%7D&t=1665848303470&appid=shop_view&clientVersion=11.0.0&client=wh5&area=1_88_2888_8&uuid=16587341419872043913507"
|
||||
headers = {
|
||||
'accept': '*/*',
|
||||
'accept-encoding': 'gzip, deflate, br',
|
||||
'accept-language': 'zh-CN,zh;q=0.9',
|
||||
'cookie': ck,
|
||||
'origin': 'https://shop.m.jd.com',
|
||||
'referer': 'https://shop.m.jd.com/',
|
||||
'user-agent': ua
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
res = response.json()
|
||||
return res
|
||||
|
||||
def sign(ua, ck, shopId, venderId):
|
||||
url = f"https://api.m.jd.com/client.action?functionId=whx_sign&body=%7B%22shopId%22%3A%22{shopId}%22%2C%22venderId%22%3A%22{venderId}%22%2C%22source%22%3A%22m-shop%22%7D&t=1665847166130&appid=shop_view&clientVersion=11.0.0&client=wh5&area=1_88_2888_8&uuid=16587341419872043913507"
|
||||
headers = {
|
||||
'accept': '*/*',
|
||||
'accept-encoding': 'gzip, deflate, br',
|
||||
'accept-language': 'zh-CN,zh;q=0.9',
|
||||
'cookie': ck,
|
||||
'origin': 'https://shop.m.jd.com',
|
||||
'referer': 'https://shop.m.jd.com/',
|
||||
'user-agent': ua
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
res = response.json()
|
||||
return res
|
||||
|
||||
def get_venderId(ua, ck, shopId):
|
||||
url = f'https://api.m.jd.com/client.action?functionId=whx_getMShopOutlineInfo&body=%7B%22shopId%22%3A%22{shopId}%22%2C%22source%22%3A%22m-shop%22%7D&appid=shop_view&clientVersion=11.0.0&client=wh5'
|
||||
headers = {
|
||||
'accept': '*/*',
|
||||
'accept-encoding': 'gzip, deflate, br',
|
||||
'accept-language': 'zh-CN,zh;q=0.9',
|
||||
'origin': 'https://shop.m.jd.com',
|
||||
'referer': 'https://shop.m.jd.com/',
|
||||
'user-agent': ua,
|
||||
'cookie': ck
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
res = response.json()
|
||||
try:
|
||||
if res['success']:
|
||||
venderId = res['data']['shopInfo']['venderId']
|
||||
return venderId
|
||||
else:
|
||||
return shopId
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
global msg
|
||||
msg = ''
|
||||
shopIds = dpcj.split('&')
|
||||
print(f"✅成功获取{len(shopIds)}个DPCJ🆔变量")
|
||||
try:
|
||||
cks = getCk
|
||||
if not cks:
|
||||
sys.exit()
|
||||
except:
|
||||
print("未获取到有效COOKIE,退出程序!")
|
||||
sys.exit()
|
||||
num = 0
|
||||
for cookie in cks:
|
||||
num += 1
|
||||
if num % 9 == 0:
|
||||
print("⏰等待3s,休息一下")
|
||||
time.sleep(3)
|
||||
ua = userAgent()
|
||||
try:
|
||||
pt_pin = re.compile(r'pt_pin=(.*?);').findall(cookie)[0]
|
||||
pt_pin = unquote_plus(pt_pin)
|
||||
except IndexError:
|
||||
pt_pin = f'用户{num}'
|
||||
print(f'\n******开始【京东账号{num}】{pt_pin} *********\n')
|
||||
print(datetime.now())
|
||||
|
||||
result = check(ua, cookie)
|
||||
if result['code'] != 200:
|
||||
print(f"‼️{result['data']}")
|
||||
continue
|
||||
signRewards = []
|
||||
for shopId in shopIds:
|
||||
print(f"{shopId}")
|
||||
venderId = get_venderId(ua, cookie, shopId)
|
||||
time.sleep(0.2)
|
||||
if not venderId:
|
||||
continue
|
||||
signInfo = getSignInfo(ua, cookie, shopId, venderId)
|
||||
time.sleep(0.2)
|
||||
try:
|
||||
if signInfo['isSuccess']:
|
||||
try:
|
||||
signInfo_ = signInfo['result']['result']['signInfo']
|
||||
except:
|
||||
print(f"\t⛈店铺抽奖已过期")
|
||||
continue
|
||||
if signInfo_['isSign'] == 2:
|
||||
print(f"\t⛈店铺已抽奖")
|
||||
else:
|
||||
toSign = sign(ua, cookie, shopId, venderId)
|
||||
if toSign['isSuccess']:
|
||||
if toSign['result']['result']['isWin']:
|
||||
signReward = toSign['result']['result']['signReward']['name']
|
||||
print(f"\t🎉{signReward}")
|
||||
if "东券" in signReward or "购原价" in signReward:
|
||||
continue
|
||||
signRewards.append(signReward)
|
||||
else:
|
||||
print("\t💨💨💨")
|
||||
except:
|
||||
continue
|
||||
# time.sleep(0.3)
|
||||
if signRewards:
|
||||
price = ','.join(signRewards)
|
||||
msg += f'【账号{num}】{pt_pin} 🎉{price}\n'
|
||||
|
||||
time.sleep(0.5)
|
||||
|
||||
title = "🗣消息提醒:店铺抽奖-JK"
|
||||
msg = f"⏰{str(datetime.now())[:19]}\n" + msg
|
||||
send(title, msg)
|
@ -1,421 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
File: jd_inviteFriendsGift.py(邀好友赢大礼)
|
||||
Author: Fix by HarbourJ
|
||||
Date: 2022/7/6 23:26
|
||||
TG: https://t.me/HarbourToulu
|
||||
cron: 1 1 1 1 1 1
|
||||
new Env('邀好友赢大礼');
|
||||
ActivityEntry:https://prodev.m.jd.com/mall/active/dVF7gQUVKyUcuSsVhuya5d2XD4F/index.html?code=xxxxxxxx&invitePin=xxxxxx
|
||||
UpdateRecord: 2022.07.06 增加从环境变量中获取authorCode变量,增加对青龙desi JD_COOKIE的适配;
|
||||
2022.10.01 修复由于若干接口被更换导致的异常报错
|
||||
Description: 变量:export jd_inv_authorCode="5f29b7dbcfad44548b685a4d8d151e59"
|
||||
"""
|
||||
|
||||
import requests, random, time, asyncio, re, os, sys, json
|
||||
from datetime import datetime
|
||||
from sendNotify import *
|
||||
from urllib.parse import quote_plus, unquote_plus
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
from functools import partial
|
||||
print = partial(print, flush=True)
|
||||
try:
|
||||
from jd_sign import *
|
||||
except ImportError as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
print("请先运行Faker库依赖一键安装脚本(jd_check_dependent.py),安装jd_sign.so依赖")
|
||||
sys.exit()
|
||||
try:
|
||||
from jdCookie import get_cookies
|
||||
getCk = get_cookies()
|
||||
except:
|
||||
print("请先下载依赖脚本,\n下载链接:https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
|
||||
sys.exit(3)
|
||||
|
||||
activatyname = '邀请赢大礼'
|
||||
activityId = 'dVF7gQUVKyUcuSsVhuya5d2XD4F' # 活动类型
|
||||
|
||||
authorCode = os.environ.get("jd_inv_authorCode") if os.environ.get("jd_inv_authorCode") else ""
|
||||
|
||||
if not authorCode:
|
||||
print("⚠️未发现有效活动变量jd_inv_authorCode,退出程序!")
|
||||
sys.exit()
|
||||
|
||||
# 检测ck状态
|
||||
async def check(ua, ck):
|
||||
try:
|
||||
url = 'https://me-api.jd.com/user_new/info/GetJDUserInfoUnion'
|
||||
header = {
|
||||
"Host": "me-api.jd.com",
|
||||
"Accept": "*/*",
|
||||
"Connection": "keep-alive",
|
||||
"Cookie": ck,
|
||||
"User-Agent": ua,
|
||||
"Accept-Language": "zh-cn",
|
||||
"Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&",
|
||||
"Accept-Encoding": "gzip, deflate",
|
||||
}
|
||||
result = requests.get(url=url, headers=header, timeout=None).text
|
||||
codestate = json.loads(result)
|
||||
if codestate['retcode'] == '1001':
|
||||
msg = "⚠️当前ck已失效,请检查"
|
||||
return {'code': 1001, 'data': msg}
|
||||
elif codestate['retcode'] == '0' and 'userInfo' in codestate['data']:
|
||||
nickName = codestate['data']['userInfo']['baseInfo']['nickname']
|
||||
return {'code': 200, 'name': nickName, 'ck': ck}
|
||||
except Exception as e:
|
||||
return {'code': 0, 'data': e}
|
||||
|
||||
# 获取当前时间
|
||||
def get_time():
|
||||
time_now = round(time.time() * 1000)
|
||||
return time_now
|
||||
|
||||
# 登录plogin
|
||||
async def plogin(ua, cookie):
|
||||
now = get_time()
|
||||
url = f'https://plogin.m.jd.com/cgi-bin/ml/islogin?time={now}&callback=__jsonp{now - 2}&_={now + 2}'
|
||||
header = {
|
||||
'Accept': '*/*',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Connection': 'keep-alive',
|
||||
'Cookie': cookie,
|
||||
'Host': 'plogin.m.jd.com',
|
||||
'Referer': 'https://prodev.m.jd.com/',
|
||||
'User-Agent': ua
|
||||
}
|
||||
response = requests.get(url=url, headers=header, timeout=None).text
|
||||
return response
|
||||
|
||||
# 邀请排名
|
||||
async def memberBringRanking(ua, cookie):
|
||||
t = get_time()
|
||||
body = {
|
||||
"code": authorCode,
|
||||
"pageNum": 1,
|
||||
"pageSize": 10
|
||||
}
|
||||
url = f"https://api.m.jd.com/api?client=&clientVersion=&appid=jdchoujiang_h5&t={t}&functionId=memberBringRanking&body={json.dumps(body)}&code={authorCode}&pageNum=1&pageSize=10"
|
||||
headers = {
|
||||
'accept': '*/*',
|
||||
'accept-encoding': 'gzip, deflate, br',
|
||||
'accept-language': 'zh-CN,zh;q=0.9',
|
||||
'content-type': 'application/json',
|
||||
'cookie': cookie,
|
||||
'origin': 'https://prodev.m.jd.com',
|
||||
'referer': 'https://prodev.m.jd.com/',
|
||||
'user-agent': ua
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers).text
|
||||
print(response)
|
||||
return json.loads(response)
|
||||
|
||||
# 活动接口 new
|
||||
async def memberBringActPage(ua, cookie):
|
||||
t = get_time()
|
||||
body = {
|
||||
"code": authorCode,
|
||||
"invitePin": invitePin,
|
||||
"_t": t
|
||||
}
|
||||
url = f"https://api.m.jd.com/api?client=&clientVersion=&appid=jdchoujiang_h5&t={t}&functionId=memberBringActPage&body={json.dumps(body)}&code={authorCode}&invitePin={invitePin}&_t={t}"
|
||||
headers = {
|
||||
'accept': '*/*',
|
||||
'accept-encoding': 'gzip, deflate, br',
|
||||
'accept-language': 'zh-CN,zh;q=0.9',
|
||||
'content-type': 'application/json',
|
||||
'cookie': cookie,
|
||||
'origin': 'https://prodev.m.jd.com',
|
||||
'referer': 'https://prodev.m.jd.com/',
|
||||
'user-agent': ua
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers).text
|
||||
# print(response)
|
||||
return json.loads(response)
|
||||
|
||||
# go开卡 new
|
||||
async def memberBringJoinMember(ua, cookie):
|
||||
t = get_time()
|
||||
body = {
|
||||
"code": authorCode,
|
||||
"invitePin": invitePin
|
||||
}
|
||||
url = f"https://api.m.jd.com/api?client=&clientVersion=&appid=jdchoujiang_h5&t={t}&functionId=memberBringJoinMember&body={json.dumps(body)}&code={authorCode}&invitePin={invitePin}"
|
||||
headers = {
|
||||
'accept': '*/*',
|
||||
'accept-encoding': 'gzip, deflate, br',
|
||||
'accept-language': 'zh-CN,zh;q=0.9',
|
||||
'content-type': 'application/json',
|
||||
'cookie': cookie,
|
||||
'origin': 'https://prodev.m.jd.com',
|
||||
'referer': 'https://prodev.m.jd.com/',
|
||||
'user-agent': ua
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers).text
|
||||
return json.loads(response)
|
||||
|
||||
async def check_ruhui(body, cookie, venderId, ua):
|
||||
url = f'https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body={json.dumps(body)}&client=H5&clientVersion=9.2.0&uuid=88888'
|
||||
headers = {
|
||||
'Host': 'api.m.jd.com',
|
||||
'Accept': '*/*',
|
||||
'Connection': 'keep-alive',
|
||||
'Cookie': cookie,
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-cn',
|
||||
'Referer': f'https://shopmember.m.jd.com/shopcard/?venderId={venderId}&channel=801&returnUrl={json.dumps(activityUrl)}',
|
||||
'Accept-Encoding': 'gzip, deflate'
|
||||
}
|
||||
response = requests.get(url=url, headers=headers, timeout=None).text
|
||||
return json.loads(response)
|
||||
|
||||
# 领取奖励 new
|
||||
async def memberBringInviteReward(cookie, ua, number):
|
||||
t = get_time()
|
||||
body = {
|
||||
"code": authorCode,
|
||||
"stage": number
|
||||
}
|
||||
url = f"https://api.m.jd.com/api?client=&clientVersion=&appid=jdchoujiang_h5&t={t}&functionId=memberBringInviteReward&body={body}&code={authorCode}&stage={number}"
|
||||
headers = {
|
||||
'accept': '*/*',
|
||||
'accept-encoding': 'gzip, deflate, br',
|
||||
'accept-language': 'zh-CN,zh;q=0.9',
|
||||
'content-type': 'application/json',
|
||||
'cookie': cookie,
|
||||
'origin': 'https://prodev.m.jd.com',
|
||||
'referer': 'https://prodev.m.jd.com/',
|
||||
'user-agent': ua
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers).text
|
||||
return json.loads(response)
|
||||
|
||||
# 开启活动
|
||||
async def memberBringFirstInvite(cookie, ua):
|
||||
body = {
|
||||
"code": authorCode,
|
||||
}
|
||||
url = f"https://api.m.jd.com/api?client=&clientVersion=&appid=jdchoujiang_h5&t=1664407539127&functionId=memberBringFirstInvite&body={json.dumps(body)}&code={authorCode}"
|
||||
headers = {
|
||||
'accept': '*/*',
|
||||
'accept-encoding': 'gzip, deflate, br',
|
||||
'accept-language': 'zh-CN,zh;q=0.9',
|
||||
'content-type': 'application/json',
|
||||
'cookie': cookie,
|
||||
'origin': 'https://prodev.m.jd.com',
|
||||
'referer': 'https://prodev.m.jd.com/',
|
||||
'user-agent': ua
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers).text
|
||||
return json.loads(response)
|
||||
|
||||
async def get_ck(data):
|
||||
cklist = []
|
||||
if data['code'] != 200:
|
||||
return {'code': 0, 'data': data}
|
||||
else:
|
||||
env_data = data['data']
|
||||
for ck in env_data:
|
||||
if 'remarks' in ck and ck['name'] == 'JD_COOKIE':
|
||||
cklist.append(ck['value'])
|
||||
else:
|
||||
pass
|
||||
return cklist
|
||||
|
||||
# 检查pin
|
||||
def checkpin(cks: list, pin):
|
||||
for ck in cks:
|
||||
if pin in ck:
|
||||
return ck
|
||||
else:
|
||||
None
|
||||
|
||||
# 主程序
|
||||
async def main():
|
||||
try:
|
||||
cks = getCk
|
||||
if not cks:
|
||||
return
|
||||
except:
|
||||
print("未获取到有效COOKIE,退出程序!")
|
||||
return
|
||||
success = 0 # 计算成功数
|
||||
global invitePin, activityUrl, MSG
|
||||
MSG = ''
|
||||
title = "🗣消息提醒:邀好友赢大礼"
|
||||
r = re.compile(r"pt_pin=(.*?);")
|
||||
invitePin_ = r.findall(cks[0])[0] # 获取COOKIES中第一个车头pin
|
||||
inveteck = checkpin(cks, invitePin_) # 根据设定的pin返回对应ck
|
||||
try:
|
||||
invitePin = remote_redis(f"invite_{authorCode}", 1)
|
||||
if not invitePin:
|
||||
invitePin = invitePin_
|
||||
except:
|
||||
invitePin = invitePin_
|
||||
activityUrl = f'https://prodev.m.jd.com/mall/active/{activityId}/index.html?code={authorCode}&invitePin={invitePin}' # 活动链接
|
||||
needinviteNum = [] # 需要助力次数
|
||||
needdel = []
|
||||
need = []
|
||||
if inveteck:
|
||||
print(f"📝若已加入活动店铺会员,则无法助力。\n【🛳活动入口】https://prodev.m.jd.com/mall/active/{activityId}/index.html?code={authorCode}\n")
|
||||
ua = userAgent() # 获取ua
|
||||
result = await check(ua, inveteck) # 检测ck
|
||||
if result['code'] == 200:
|
||||
await plogin(ua, inveteck) # 获取登录状态
|
||||
await asyncio.sleep(2)
|
||||
result = await memberBringActPage(ua, inveteck) # 获取活动信息
|
||||
await memberBringFirstInvite(inveteck, ua) # 开启活动
|
||||
if result['success']:
|
||||
brandName = result['data']['brandName'] # 店铺名字
|
||||
venderId = result['data']['venderId'] # 店铺入会id
|
||||
rewardslist = [] # 奖品
|
||||
rewardNameList = []
|
||||
successCount = result['data']['successCount'] # 当前成功数
|
||||
success += successCount
|
||||
result_data = result['data']['rewards'] # 奖品数据
|
||||
print(f'🤖您好!账号[{invitePin_}]\n✅开启{brandName}邀请好友活动\n去开活动')
|
||||
MSG += f'✅账号[{invitePin_}]\n开启{brandName}邀请好友活动\n📝活动地址https://prodev.m.jd.com/mall/active/{activityId}/index.html?code={authorCode}\n'
|
||||
for i in result_data:
|
||||
stage = i['stage']
|
||||
inviteNum = i['inviteNum'] # 单次需要拉新人数
|
||||
need.append(inviteNum)
|
||||
rewardName = i['rewardName'] # 奖品名
|
||||
rewardNameList.append(rewardName)
|
||||
rewardNum = i['rewardStock']
|
||||
if rewardNum != 0:
|
||||
needinviteNum.append(inviteNum)
|
||||
needdel.append(inviteNum)
|
||||
rewardslist.append(f'级别{stage}: 需助力{inviteNum}人,奖品: {rewardName},库存:{rewardNum}件\n')
|
||||
if len(rewardslist) != 0:
|
||||
print('🎁当前活动奖品如下: \n' + str('\n'.join(rewardslist)) + f'\n当前已助力{successCount}次\n')
|
||||
MSG += f"🎁当前活动奖品如下: \n{str(''.join(rewardslist))}\n"
|
||||
for numbers in needdel:
|
||||
if success >= numbers:
|
||||
print("🎉您当前助力已经满足了,可以去领奖励了")
|
||||
print(f'\n📝这就去领取奖励{need.index(numbers) + 1}')
|
||||
result = await memberBringInviteReward(inveteck, ua, need.index(numbers) + 1)
|
||||
try:
|
||||
if result['success']:
|
||||
print(f"🎉成功领取 {rewardNameList[need.index(numbers)]}")
|
||||
MSG += f"🎉成功领取 {rewardNameList[need.index(numbers)]}\n"
|
||||
else:
|
||||
print(f"⛈{rewardNameList[need.index(numbers)]} {result['errorMessage']}")
|
||||
MSG += f"⛈{rewardNameList[need.index(numbers)]} {result['errorMessage']}\n"
|
||||
except:
|
||||
print(result)
|
||||
MSG += f"{result}\n"
|
||||
needinviteNum.remove(numbers)
|
||||
await asyncio.sleep(10)
|
||||
needdel = needinviteNum
|
||||
if needinviteNum == []:
|
||||
print('🎉🎉🎉奖励已经全部获取啦,退出程序')
|
||||
MSG += f"🎉🎉🎉奖励已经全部获取啦~\n"
|
||||
MSG = f"⏰{str(datetime.now())[:19]}\n" + MSG
|
||||
send(title, MSG)
|
||||
return
|
||||
for n, ck in enumerate(cks, 1):
|
||||
ua = userAgent() # 获取ua
|
||||
try:
|
||||
pin = re.findall(r'(pt_pin=([^; ]+)(?=;))', str(ck))[0]
|
||||
pin = (unquote_plus(pin[1]))
|
||||
except IndexError:
|
||||
pin = f'用户{n}'
|
||||
print(f'******开始【京东账号{n}】{pin} *********\n')
|
||||
for i, numbers in enumerate(needinviteNum, 1):
|
||||
for numbers in needdel:
|
||||
if success >= numbers:
|
||||
print(numbers)
|
||||
print("🎉您当前助力已经满足了,可以去领奖励了")
|
||||
print(f'\n📝这就去领取奖励{need.index(numbers) + 1}')
|
||||
result = await memberBringInviteReward(inveteck, ua, need.index(numbers) + 1)
|
||||
try:
|
||||
if result['success']:
|
||||
print(f"🎉成功领取 {rewardNameList[need.index(numbers)]}")
|
||||
MSG += f"🎉成功领取 {rewardNameList[need.index(numbers)]}\n"
|
||||
else:
|
||||
print(f"⛈{rewardNameList[need.index(numbers)]} {result['errorMessage']}")
|
||||
MSG += f"⛈{rewardNameList[need.index(numbers)]} {result['errorMessage']}\n"
|
||||
except:
|
||||
print(result)
|
||||
MSG += f"{result}\n"
|
||||
needinviteNum.remove(numbers)
|
||||
await asyncio.sleep(10)
|
||||
needdel = needinviteNum
|
||||
if needinviteNum == []:
|
||||
print('🎉🎉🎉奖励已经全部获取啦,退出程序')
|
||||
MSG += f"🎉🎉🎉奖励已经全部获取啦~\n"
|
||||
MSG = f"⏰{str(datetime.now())[:19]}\n" + MSG
|
||||
send(title, MSG)
|
||||
return
|
||||
await plogin(ua, ck) # 获取登录状态
|
||||
result = await check(ua, ck) # 检测ck
|
||||
if n != 1:
|
||||
invitePin = invitePin_
|
||||
activityUrl = f'https://prodev.m.jd.com/mall/active/{activityId}/index.html?code={authorCode}&invitePin={invitePin}'
|
||||
if result['code'] == 200:
|
||||
result = await memberBringActPage(ua, ck) # 调用ck
|
||||
if result['success']:
|
||||
print(f'✅账户[{pin}]已开启{brandName}邀请好友活动\n')
|
||||
await asyncio.sleep(3)
|
||||
result = await check_ruhui({"venderId": str(venderId), "channel": "401"}, ck, venderId,
|
||||
ua) # 检查入会状态
|
||||
try:
|
||||
if result['result']['userInfo']['openCardStatus'] == 0: # 0 未开卡
|
||||
await asyncio.sleep(2)
|
||||
print(f'😆您还不是会员哦,这就去去助力{invitePin}\n')
|
||||
result = await memberBringJoinMember(ua, ck)
|
||||
if result['success']:
|
||||
success += 1
|
||||
print(f'🎉助力成功! 当前成功助力{success}个\n')
|
||||
else:
|
||||
if '交易失败' in str(result):
|
||||
success += 1
|
||||
print(f'🎉助力成功! 当前成功助力{success}个\n')
|
||||
else:
|
||||
try:
|
||||
print(f"⛈{result['errorMessage']}")
|
||||
except:
|
||||
print(result)
|
||||
await asyncio.sleep(2)
|
||||
else:
|
||||
print('⛈您已经是会员啦,不去请求入会了\n')
|
||||
continue
|
||||
except TypeError as e:
|
||||
print(e)
|
||||
result = await memberBringJoinMember(ua, ck)
|
||||
if result['success']:
|
||||
success += 1
|
||||
print(f'🎉助力成功! 当前成功助力{success}个\n')
|
||||
else:
|
||||
if '交易失败' in result:
|
||||
success += 1
|
||||
print(f'🎉助力成功! 当前成功助力{success}个\n')
|
||||
else:
|
||||
print(f"⛈{result['errorMessage']}")
|
||||
await asyncio.sleep(2)
|
||||
if n == 1:
|
||||
await memberBringFirstInvite(inveteck, ua) # 开启邀请
|
||||
|
||||
else: # 没有获取到活动信息
|
||||
print('未获取到活动参数信息\n')
|
||||
break
|
||||
else:
|
||||
print(result['data'])
|
||||
continue
|
||||
else:
|
||||
print('未能获取到活动信息\n')
|
||||
return
|
||||
|
||||
else:
|
||||
print(result['data'])
|
||||
return
|
||||
else:
|
||||
print(f'pin填写有误,请重试')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
@ -1,84 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
File: jd_jingBeanReceive.py(plus专属礼-天天领福利)
|
||||
Author: HarbourJ
|
||||
Date: 2022/9/19 22:00
|
||||
TG: https://t.me/HarbourToulu
|
||||
TgChat: https://t.me/HarbourSailing
|
||||
cron: 30 0 0 * * *
|
||||
new Env('plus专属礼-天天领福利');
|
||||
"""
|
||||
|
||||
import requests, sys, os, re, time
|
||||
from datetime import datetime
|
||||
from urllib.parse import quote_plus, unquote_plus
|
||||
from functools import partial
|
||||
print = partial(print, flush=True)
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
|
||||
try:
|
||||
from jd_sign import *
|
||||
except ImportError as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
print("请先运行Faker库依赖一键安装脚本(jd_check_dependent.py),安装jd_sign.so依赖")
|
||||
try:
|
||||
from jdCookie import get_cookies
|
||||
getCk = get_cookies()
|
||||
except:
|
||||
print("请先下载依赖脚本,\n下载链接: https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
|
||||
sys.exit(3)
|
||||
|
||||
def randomString(e, flag=False):
|
||||
t = "0123456789abcdef"
|
||||
if flag: t = t.upper()
|
||||
n = [random.choice(t) for _ in range(e)]
|
||||
return ''.join(n)
|
||||
|
||||
def doTask(cookie):
|
||||
url = "https://api.m.jd.com/client.action?functionId=jingBeanReceive"
|
||||
payload = "avifSupport=1&body=%7B%22encryptAssignmentId%22%3A%226bzcu8ZNPHFhuWZC55MhLgJCPiW%22%2C%22firstType%22%3A1%7D&build=168311&client=apple&clientVersion=11.2.7&d_brand=apple&d_model=iPhone10%2C3&ef=1&eid=eidI21de81220cs4zwVxJDcwTxubBP9xskb8as8Fcpw827kSwFhxTs/xaamHiBAVj7C/YnZR%2BmODl1OUeH7f5I4xm/mIct00P8O2cmBrp3PIKEq208Zs&ep=%7B%22ciphertype%22%3A5%2C%22cipher%22%3A%7B%22screen%22%3A%22CJOyDIeyDNC2%22%2C%22wifiBssid%22%3A%22YtPwC2VrZWPrCJKmZNO4CNS3ENUnZWUzYJSmCwDuCNS%3D%22%2C%22osVersion%22%3A%22CJUkCy4n%22%2C%22area%22%3A%22CJvpCJYmCV8zDtCzXzYzCtUy%22%2C%22openudid%22%3A%22DwO2Czu5YJY1DQC2EJYmCzLvYJu5DJZrDNq1ZNDsZJPvDJVuDzO0ZG%3D%3D%22%2C%22uuid%22%3A%22aQf1ZRdxb2r4ovZ1EJZhcxYlVNZSZz09%22%7D%2C%22ts%22%3A1664322556%2C%22hdid%22%3A%22JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw%3D%22%2C%22version%22%3A%221.0.3%22%2C%22appname%22%3A%22com.360buy.jdmobile%22%2C%22ridx%22%3A-1%7D&ext=%7B%22prstate%22%3A%220%22%2C%22pvcStu%22%3A%221%22%7D&isBackground=N&joycious=90&lang=zh_CN&networkType=wifi&networklibtype=JDNetworkBaseAF&partner=apple&rfs=0000&scope=11&sign=1068e427417088f66b6662841e9188b3&st=1664322629327&sv=111&uemps=0-0&uts=0f31TVRjBSsM4O1yK5LGrapaX3BEwS6R%2BmwPNn9dovB4gt4APFjVvh%2BoNgcWzJXrDASiBpSRQ3pc9ekEO5KCoTMPhPrXYRqXLR8bzfr3d%2B2gW/%2BNqeVTOVl22fjzmPi2glE4SD40Tb4WoZL4BC1v4ZOyc0E4NuLooRD0h6AO3RS64giA6YOFQa7z6Lnnnb8DCffGL0/zm0UQEfnIKCK8SA%3D%3D"
|
||||
headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Cookie': cookie,
|
||||
'Host': 'api.m.jd.com',
|
||||
'User-Agent': ua
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
try:
|
||||
res = response.json()
|
||||
if res['isSuccess']:
|
||||
print(f"🎉 {res['data']['windowsContent']}")
|
||||
else:
|
||||
print(f"⛈ {res['message']}")
|
||||
except:
|
||||
print(response.text)
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
cks = getCk
|
||||
if not cks:
|
||||
sys.exit()
|
||||
except:
|
||||
print("未获取到有效COOKIE,退出程序!")
|
||||
sys.exit()
|
||||
num = 0
|
||||
for cookie in cks[:]:
|
||||
num += 1
|
||||
global ua
|
||||
ua = userAgent()
|
||||
try:
|
||||
pt_pin = re.compile(r'pt_pin=(.*?);').findall(cookie)[0]
|
||||
pt_pin = unquote_plus(pt_pin)
|
||||
except IndexError:
|
||||
pt_pin = f'用户{num}'
|
||||
print(f'\n******开始【京东账号{num}】{pt_pin} *********\n')
|
||||
print(datetime.now())
|
||||
doTask(cookie)
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
|
@ -1,558 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
File: jd_jinggengInvite.py(jinggeng邀请入会有礼)
|
||||
Author: HarbourJ
|
||||
Date: 2022/8/1 22:37
|
||||
TG: https://t.me/HarbourToulu
|
||||
cron: 1 1 1 1 1 1
|
||||
new Env('jinggeng邀请入会有礼');
|
||||
活动入口: https://jinggeng-isv.isvjcloud.com/ql/front/showInviteJoin?id=9e80809282a4bdc90182ab254c7e0a12&user_id=1000121005
|
||||
变量设置: export redis_url="xxx", export redis_port="xxx"(没有可省略), export redis_pwd="xxx"(没有可省略)
|
||||
export jinggengInviteJoin="9e80809282a4bdc90182ab254c7e0a12&1000121005"(活动id&店铺id)
|
||||
Update: 2022/11/01 更新入会算法,内置船新入会本地算法
|
||||
"""
|
||||
|
||||
import time, requests, sys, re, os, json, random
|
||||
from bs4 import BeautifulSoup
|
||||
from datetime import datetime
|
||||
from urllib.parse import quote_plus, unquote_plus
|
||||
from functools import partial
|
||||
print = partial(print, flush=True)
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
try:
|
||||
from jd_sign import *
|
||||
except ImportError as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
print("请先运行Faker库依赖一键安装脚本(jd_check_dependent.py),安装jd_sign.so依赖")
|
||||
try:
|
||||
from jdCookie import get_cookies
|
||||
getCk = get_cookies()
|
||||
except:
|
||||
print("请先下载依赖脚本,\n下载链接: https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
|
||||
sys.exit(3)
|
||||
redis_url = os.environ.get("redis_url") if os.environ.get("redis_url") else "172.17.0.1"
|
||||
redis_port = os.environ.get("redis_port") if os.environ.get("redis_port") else "6379"
|
||||
redis_pwd = os.environ.get("redis_pwd") if os.environ.get("redis_pwd") else ""
|
||||
jinggengInviteJoin = os.environ.get("jinggengInviteJoin") if os.environ.get("jinggengInviteJoin") else ""
|
||||
|
||||
inviterNicks = [
|
||||
"Ny0m1K1tVHIJvt0j4SQ9RbRPXMHHf%2BDrNmMVfT8S5hq3SjYMAACrbEHZQ40J5yPY",
|
||||
"pWGUWZJQ3actex0X2vQyLsjNhNaYFy2HteErE6izlhTf9nrGY7gBkCdGU4C6z%2FxD",
|
||||
"3TQTImsIN0s9T85f1wS70V4tLNYA4seuA67MOIYQxEk3Vl9%2BAVo4NF%2BtgyeIc6A6kdK3rLBQpEQH9V4tdrrh0w%3D%3D"
|
||||
]
|
||||
if "&" not in jinggengInviteJoin:
|
||||
print("⚠️jinggengInviteJoin变量有误!退出程序!")
|
||||
sys.exit()
|
||||
ac_id = jinggengInviteJoin.split("&")[0]
|
||||
user_id = jinggengInviteJoin.split("&")[1]
|
||||
inviterNick = random.choice(inviterNicks)
|
||||
activity_url = f"https://jinggeng-isv.isvjcloud.com/ql/front/showInviteJoin?id={ac_id}&user_id={user_id}&inviterNick={inviterNick}"
|
||||
print(f"【🛳活动入口】https://jinggeng-isv.isvjcloud.com/ql/front/showInviteJoin?id={ac_id}&user_id={user_id}")
|
||||
|
||||
def redis_conn():
|
||||
try:
|
||||
import redis
|
||||
try:
|
||||
pool = redis.ConnectionPool(host=redis_url, port=redis_port, decode_responses=True, socket_connect_timeout=5, password=redis_pwd)
|
||||
r = redis.Redis(connection_pool=pool)
|
||||
r.get('conn_test')
|
||||
print('✅redis连接成功')
|
||||
return r
|
||||
except:
|
||||
print("⚠️redis连接异常")
|
||||
except:
|
||||
print("⚠️缺少redis依赖,请运行pip3 install redis")
|
||||
|
||||
def getToken(ck, r=None):
|
||||
try:
|
||||
# redis缓存Token 活动域名+pt_pin
|
||||
pt_pin = unquote_plus(re.compile(r'pt_pin=(.*?);').findall(ck)[0])
|
||||
except:
|
||||
# redis缓存Token 活动域名+ck前7位(获取pin失败)
|
||||
pt_pin = ck[:15]
|
||||
try:
|
||||
if r is not None:
|
||||
Token = r.get(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}')
|
||||
# print("Token过期时间", r.ttl(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}'))
|
||||
if Token is not None:
|
||||
print(f"♻️获取缓存Token")
|
||||
return Token
|
||||
else:
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign_txt = sign({"url": f"{activityUrl}", "id": ""}, 'isvObfuscator')
|
||||
# print(sign_txt)
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
return
|
||||
Token_new = f.json()['token']
|
||||
if r.set(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}', Token_new, ex=1800):
|
||||
print("✅Token缓存成功")
|
||||
else:
|
||||
print("❌Token缓存失败")
|
||||
return Token_new
|
||||
else:
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign_txt = sign({"url": f"{activityUrl}", "id": ""}, 'isvObfuscator')
|
||||
# print(sign_txt)
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
return
|
||||
Token = f.json()['token']
|
||||
print(f"✅获取实时Token")
|
||||
return Token
|
||||
except:
|
||||
return
|
||||
|
||||
def getJdTime():
|
||||
url = "http://api.m.jd.com/client.action?functionId=queryMaterialProducts&client=wh5"
|
||||
headers = {
|
||||
'Accept': '*/*',
|
||||
'Accept-Encoding': 'gzip, deflate',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9',
|
||||
'Host': 'api.m.jd.com',
|
||||
'Proxy-Connection': 'keep-alive',
|
||||
'Upgrade-Insecure-Requests': '1',
|
||||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36'
|
||||
}
|
||||
try:
|
||||
response = requests.request("GET", url, headers=headers, timeout=2)
|
||||
if response.status_code == 200:
|
||||
res = response.json()
|
||||
jdTime = res['currentTime2']
|
||||
except:
|
||||
jdTime = int(round(time.time() * 1000))
|
||||
return jdTime
|
||||
|
||||
def randomString(e, flag=False):
|
||||
t = "0123456789abcdef"
|
||||
if flag: t = t.upper()
|
||||
n = [random.choice(t) for _ in range(e)]
|
||||
return ''.join(n)
|
||||
|
||||
def refresh_cookies(res):
|
||||
if res.cookies:
|
||||
cookies = res.cookies.get_dict()
|
||||
set_cookie = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
global activityCookie
|
||||
activityCookieMid = [i for i in activityCookie.split(';') if i != '']
|
||||
for i in activityCookieMid:
|
||||
for x in set_cookie:
|
||||
if i.split('=')[0] == x.split('=')[0]:
|
||||
if i.split('=')[1] != x.split('=')[1]:
|
||||
activityCookieMid.remove(i)
|
||||
activityCookie = ''.join(sorted([(set_cookie + ";") for set_cookie in list(set(activityCookieMid + set_cookie))]))
|
||||
|
||||
def getActivity(index=1, isOpenCard=0, inviterCode=None, getIndex=0):
|
||||
url = f"{activityUrl}&isOpenCard={isOpenCard}&from=kouling"
|
||||
if len(token) == 0:
|
||||
IsvToken = ''
|
||||
else:
|
||||
IsvToken = f"IsvToken={token};"
|
||||
headers = {
|
||||
'Host': 'jinggeng-isv.isvjcloud.com',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Connection': 'keep-alive',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Referer': url,
|
||||
'Cookie': IsvToken + activityCookie
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
html_text = response.text
|
||||
if response.status_code == 493:
|
||||
print(response.status_code, "⚠️ip疑似黑了,休息一会再来撸~")
|
||||
sys.exit()
|
||||
# if response.cookies:
|
||||
cookies = response.cookies.get_dict()
|
||||
set_cookies = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
set_cookie = ''.join(sorted([(set_cookie + ";") for set_cookie in set_cookies]))
|
||||
if getIndex == 3:
|
||||
return set_cookie
|
||||
if "活动时间" in html_text:
|
||||
refresh_cookies(response)
|
||||
soup = BeautifulSoup(html_text, 'html.parser')
|
||||
errorMsg = soup.find('input', attrs={'id': 'errorMsg'})['value']
|
||||
inviteSucc = soup.find('input', attrs={'id': 'inviteSucc'})['value']
|
||||
if len(errorMsg) != 0:
|
||||
errorMsg0 = errorMsg
|
||||
if len(inviteSucc) != 0:
|
||||
errorMsg0 = inviteSucc
|
||||
if index == 1:
|
||||
if getIndex == 2:
|
||||
pass
|
||||
shop_title = soup.find('input', attrs={'id': 'shop_title'})['value'].replace(' ', '')
|
||||
actName = soup.find('input', attrs={'id': 'actName'})['value']
|
||||
shop_sid = soup.find('input', attrs={'id': 'shop_sid'})['value']
|
||||
inviteSuccNums = (soup.find('input', attrs={'id': 'helpLogs'})['value'])
|
||||
inviteSetting2s = eval(soup.find('input', attrs={'id': 'inviteSetting2'})['value'])
|
||||
print(f"店铺名称: {shop_title} \n活动名称: {actName} \n店铺ID: {shop_sid}")
|
||||
num1 = {'1': 'one', '2': 'two', '3': 'three', '4': 'four'}
|
||||
num2 = {'1': 'leveOneNum', '2': 'leveTwoNum', '3': 'leveThreeNum', '4': 'leveFourNum'}
|
||||
needInviteNums = []
|
||||
for a in range(len(inviteSetting2s)):
|
||||
b = a + 1
|
||||
inviteSetting2 = inviteSetting2s[num1[str(b)]]
|
||||
# equityEndTime = inviteSetting2['equityEndTime']
|
||||
freezeQuantity = inviteSetting2['freezeQuantity']
|
||||
availableQuantity = inviteSetting2['availableQuantity']
|
||||
equityType = inviteSetting2['equityType']
|
||||
equityName = inviteSetting2['equityName']
|
||||
leveNum = inviteSetting2[num2[str(b)]]
|
||||
if equityType == "JD_GOODS":
|
||||
denomination = ''
|
||||
else:
|
||||
denomination = inviteSetting2['denomination']
|
||||
awardId = inviteSetting2['id']
|
||||
# inviteSucc = soup.find('input', attrs={'id': 'inviteSucc'})['value']
|
||||
print(f"奖品{b}: {equityName} 奖励: {denomination} 总数: {freezeQuantity}份 剩余: {availableQuantity}份 需要邀请: {leveNum}人")
|
||||
if availableQuantity > 0:
|
||||
needInviteNums.append((leveNum, awardId, equityType))
|
||||
if len(needInviteNums) == 0:
|
||||
print(f"⛈⛈⛈活动奖品全部发完啦!")
|
||||
sys.exit()
|
||||
return errorMsg, inviteSuccNums, needInviteNums
|
||||
return errorMsg0
|
||||
elif "活动已结束" in html_text:
|
||||
print("😭活动已结束,下次早点来~")
|
||||
sys.exit()
|
||||
else:
|
||||
return set_cookie
|
||||
|
||||
def setMixNick(token):
|
||||
url = "https://jinggeng-isv.isvjcloud.com/front/setMixNick"
|
||||
payload = f"strTMMixNick={token}&userId={user_id}&source=01"
|
||||
headers = {
|
||||
'Host': 'jinggeng-isv.isvjcloud.com',
|
||||
'Accept': 'application/json, text/javascript, */*; q=0.01',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'Origin': 'https://jinggeng-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': f'{activityUrl}&isOpenCard=0&from=kouling',
|
||||
'Content-Length': '116',
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
try:
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
res = response.text
|
||||
setMixNick0 = eval(res.replace('true', 'True').replace('false', 'False').replace('none', 'None'))['msg']
|
||||
refresh_cookies(response)
|
||||
return setMixNick0
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return
|
||||
|
||||
def recordActPvUvdata(token):
|
||||
url = "https://jinggeng-isv.isvjcloud.com/ql/front/reportActivity/recordActPvUvData"
|
||||
payload = F"userId={user_id}&actId={ac_id}"
|
||||
headers = {
|
||||
'Host': 'jinggeng-isv.isvjcloud.com',
|
||||
'Accept': 'application/json, text/javascript, */*; q=0.01',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'Origin': 'https://jinggeng-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': f'{activityUrl}&isOpenCard=0&from=kouling',
|
||||
'Content-Length': '56',
|
||||
'Cookie': f"IsvToken={token};" + activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def checkTokenInSession(token):
|
||||
url = "https://jinggeng-isv.isvjcloud.com/front/checkTokenInSession"
|
||||
payload = f"userId={user_id}&token={token}"
|
||||
headers = {
|
||||
'Host': 'jinggeng-isv.isvjcloud.com',
|
||||
'Accept': 'application/json, text/javascript, */*; q=0.01',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'Origin': 'https://jinggeng-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': f'{activityUrl}&isOpenCard=0&from=kouling',
|
||||
'Content-Length': '99',
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def shopmember(cookie):
|
||||
url = f'https://shopmember.m.jd.com/shopcard/?venderId={user_id}&channel=401&returnUrl={quote_plus(activityUrl + "&isOpenCard=1")}'
|
||||
headers = {
|
||||
'Host': 'shopmember.m.jd.com',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'Connection': 'keep-alive',
|
||||
'Cookie': cookie,
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Referer': 'https://jinggeng-isv.isvjcloud.com/',
|
||||
'Accept-Encoding': 'gzip, deflate, br'
|
||||
}
|
||||
requests.request("GET", url, headers=headers)
|
||||
|
||||
def bindWithVender(cookie):
|
||||
try:
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': ua,
|
||||
'Cookie': cookie,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': f'https://shopmember.m.jd.com/shopcard/?venderId={user_id}&returnUrl={quote_plus(activityUrl + "&isOpenCard=1")}',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
s.params = {
|
||||
'appid': 'jd_shop_member',
|
||||
'functionId': 'bindWithVender',
|
||||
'body': json.dumps({
|
||||
'venderId': user_id,
|
||||
'shopId': user_id,
|
||||
'bindByVerifyCodeFlag': 1
|
||||
}, separators=(',', ':'))
|
||||
}
|
||||
res = s.post('https://api.m.jd.com/', verify=False, timeout=30).json()
|
||||
if res['success']:
|
||||
if "火爆" in res['message'] or "失败" in res['message']:
|
||||
print(f"\t⛈⛈⛈{res['message']}")
|
||||
else:
|
||||
print(f"\t🎉🎉🎉{res['message']}")
|
||||
return res['message']
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def receiveInviteJoinAward(token, awardId):
|
||||
url = "https://jinggeng-isv.isvjcloud.com/ql/front/receiveInviteJoinAward"
|
||||
payload = f"act_id={ac_id}&user_id={user_id}&awardId={awardId}"
|
||||
headers = {
|
||||
'Host': 'jinggeng-isv.isvjcloud.com',
|
||||
'Accept': 'application/json, text/javascript, */*; q=0.01',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'Origin': 'https://jinggeng-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': f'{activityUrl}&isOpenCard=0&from=kouling&sid=09a25fb32a08d0b0fbdef65ab52a40dw&un_area=15_1213_1215_50108',
|
||||
'Content-Length': '99',
|
||||
'Cookie': f"IsvToken={token};" + activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload).text
|
||||
res = eval(response.replace('true', 'True').replace('false', 'False').replace('none', 'None'))
|
||||
if res['succ'] is True:
|
||||
msg = eval(str(res['msg']).replace('\\\\', ''))
|
||||
if msg['isSendSucc']:
|
||||
awardType = msg['drawAwardDto']['awardType'].replace('JD_BEAN', '京豆').replace('JD_POINT', '积分')
|
||||
awardDenomination = msg['drawAwardDto']['awardDenomination']
|
||||
print(f"\t🎉🎉成功领取{awardDenomination}{awardType}")
|
||||
else:
|
||||
print(f"\t🎉🎉{res['msg']}")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = redis_conn()
|
||||
try:
|
||||
cks = getCk
|
||||
if not cks:
|
||||
sys.exit()
|
||||
except:
|
||||
print("未获取到有效COOKIE,退出程序!")
|
||||
sys.exit()
|
||||
global inviterCode, inviteSuccNums, activityUrl, needInviteNums, rewardIndex, firstCk
|
||||
inviteSuccNums = 0
|
||||
inviterCode = inviterNick
|
||||
activityUrl = activity_url
|
||||
needInviteNums = None
|
||||
rewardIndex = 0
|
||||
num = 0
|
||||
for cookie in cks:
|
||||
num += 1
|
||||
if num == 1:
|
||||
firstCk = cookie
|
||||
if num % 5 == 0:
|
||||
print("⏰等待5s")
|
||||
time.sleep(5)
|
||||
global ua, activityCookie, token, getIndex
|
||||
getIndex = 0
|
||||
ua = userAgent()
|
||||
try:
|
||||
pt_pin = re.compile(r'pt_pin=(.*?);').findall(cookie)[0]
|
||||
pt_pin = unquote_plus(pt_pin)
|
||||
except IndexError:
|
||||
pt_pin = f'用户{num}'
|
||||
print(f'\n******开始【京东账号{num}】{pt_pin} *********\n')
|
||||
print(datetime.now())
|
||||
token = ''
|
||||
activityCookie = ''
|
||||
activityCookie = getActivity(num, 0, inviterCode, 0)
|
||||
try:
|
||||
token = getToken(cookie, r)
|
||||
if token is None:
|
||||
if num == 1:
|
||||
print(f"⚠️车头获取Token失败,退出本程序!")
|
||||
# sys.exit()
|
||||
os._exit()
|
||||
print(f"⚠️获取Token失败!⏰等待3s")
|
||||
time.sleep(3)
|
||||
continue
|
||||
except:
|
||||
print(f"⚠️获取Token失败!⏰等待3s")
|
||||
time.sleep(3)
|
||||
continue
|
||||
time.sleep(1.5)
|
||||
setMixNick0 = setMixNick(token)
|
||||
if setMixNick0 is None:
|
||||
if num == 1:
|
||||
print(f"⚠️车头获取邀请码失败,退出本程序!")
|
||||
sys.exit()
|
||||
else:
|
||||
continue
|
||||
else:
|
||||
print(f"邀请码->: {setMixNick0}")
|
||||
time.sleep(1)
|
||||
print(f"准备助力-->: {inviterCode}")
|
||||
inviteSuccNum = getActivity(num, 0, inviterCode, 1)
|
||||
if num == 1:
|
||||
errorMsg0 = inviteSuccNum[0]
|
||||
if "跳开卡页面" not in errorMsg0:
|
||||
print("无法助力自己")
|
||||
inviteSuccNums0 = inviteSuccNum[1]
|
||||
needInviteNums = inviteSuccNum[2]
|
||||
inviteSuccNums = len(eval(inviteSuccNums0))
|
||||
print(f"🛳已经邀请{inviteSuccNums}人")
|
||||
for i, needNum0 in enumerate(needInviteNums):
|
||||
needNum = needNum0[0]
|
||||
awardId = needNum0[1]
|
||||
equityType = needNum0[2]
|
||||
if inviteSuccNums >= needNum:
|
||||
print(f"🎉恭喜已完成第{i + 1}档邀请,快去领奖吧!")
|
||||
time.sleep(1)
|
||||
recordActPvUvdata(token)
|
||||
checkTokenInSession(token)
|
||||
time.sleep(1)
|
||||
if equityType == "JD_GOODS":
|
||||
print(f"\t🎉🎉成功获得实物奖励,请尽快前往领取:{activityUrl}")
|
||||
else:
|
||||
receiveInviteJoinAward(token, awardId)
|
||||
rewardIndex += 1
|
||||
time.sleep(3)
|
||||
if i + 1 == len(needInviteNums):
|
||||
print("🎉🎉🎉奖励全部领取完毕~")
|
||||
sys.exit()
|
||||
time.sleep(1)
|
||||
inviterCode = setMixNick0
|
||||
activityUrl = f"https://jinggeng-isv.isvjcloud.com/ql/front/showInviteJoin?id={ac_id}&user_id={user_id}&inviterNick={inviterCode}"
|
||||
continue
|
||||
else:
|
||||
errorMsg1 = inviteSuccNum
|
||||
# print("num != 1", errorMsg1)
|
||||
if "跳开卡页面" not in errorMsg1:
|
||||
if "已成功邀请您加入本店会员" in errorMsg1:
|
||||
print("⛈已经是会员了,无法完成助力")
|
||||
else:
|
||||
print(f"🛳{errorMsg1}")
|
||||
time.sleep(1)
|
||||
continue
|
||||
time.sleep(1.5)
|
||||
recordActPvUvdata(token)
|
||||
checkTokenInSession(token)
|
||||
time.sleep(1)
|
||||
shopmember(cookie)
|
||||
print("现在去开卡")
|
||||
open_result = bindWithVender(cookie)
|
||||
if open_result is not None:
|
||||
if "火爆" in open_result or "失败" in open_result:
|
||||
time.sleep(1.5)
|
||||
print("\t尝试重新入会 第1次")
|
||||
open_result = bindWithVender(cookie)
|
||||
if "火爆" in open_result or "失败" in open_result:
|
||||
time.sleep(1.5)
|
||||
print("\t尝试重新入会 第2次")
|
||||
open_result = bindWithVender(cookie)
|
||||
time.sleep(1)
|
||||
if num == 1:
|
||||
getIndex = 2
|
||||
errorMsg2 = getActivity(num, 1, inviterCode, getIndex)
|
||||
time.sleep(2)
|
||||
recordActPvUvdata(token)
|
||||
checkTokenInSession(token)
|
||||
# print(errorMsg2, '============================')
|
||||
if num == 1 and "开卡失败" in errorMsg2:
|
||||
print(f"⚠️车头疑似火爆号,退出本程序!")
|
||||
sys.exit()
|
||||
if "已成功邀请您加入本店会员" in errorMsg2:
|
||||
inviteSuccNums += 1
|
||||
print(f"🛳已经邀请{inviteSuccNums}人")
|
||||
for i, needNum1 in enumerate(needInviteNums):
|
||||
needNum = needNum1[0]
|
||||
awardId = needNum1[1]
|
||||
equityType = needNum1[2]
|
||||
if inviteSuccNums >= needNum:
|
||||
if rewardIndex >= i + 1:
|
||||
time.sleep(1)
|
||||
continue
|
||||
print(f"🎉恭喜已完成第{i + 1}档邀请,快去领奖吧!")
|
||||
token = getToken(firstCk, r)
|
||||
activityCookie = getActivity(1, 0, inviterCode, 3)
|
||||
setMixNick(token)
|
||||
time.sleep(0.5)
|
||||
recordActPvUvdata(token)
|
||||
time.sleep(0.5)
|
||||
if equityType == "JD_GOODS":
|
||||
print(f"\t🎉🎉成功获得实物奖励,请尽快前往领取:{activityUrl}")
|
||||
else:
|
||||
receiveInviteJoinAward(token, awardId)
|
||||
rewardIndex += 1
|
||||
time.sleep(3)
|
||||
if i + 1 == len(needInviteNums):
|
||||
print("🎉🎉🎉奖励全部领取完毕~")
|
||||
sys.exit()
|
||||
if num == 1:
|
||||
inviterCode = setMixNick0
|
||||
activityUrl = f"https://jinggeng-isv.isvjcloud.com/ql/front/showInviteJoin?id={ac_id}&user_id={user_id}&inviterNick={inviterCode}"
|
||||
|
||||
time.sleep(3)
|
@ -1,674 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
File: jd_joinCommon_opencard.py(通用开卡-joinCommon系列)
|
||||
Author: HarbourJ
|
||||
Date: 2022/8/12 20:37
|
||||
TG: https://t.me/HarbourToulu
|
||||
TgChat: https://t.me/HarbourSailing
|
||||
cron: 1 1 1 1 1 1
|
||||
new Env('通用开卡-joinCommon系列');
|
||||
ActivityEntry: https://lzdz1-isv.isvjcloud.com/dingzhi/joinCommon/activity?activityId=2b870a1a74504c45995a5d5119487f3a
|
||||
Description: dingzhi/joinCommon系列通用开卡脚本(通常情况下,开一张卡10豆,邀请成功获得20豆)。
|
||||
本地sign算法+redis缓存Token+代理ip(自行配置,实测可行)
|
||||
变量: export jd_joinCommonId="2b870a1a7450xxxxxxxxxxxxx&1000000904" 变量值需要传入活动id&shopId
|
||||
Update: 2022/11/01 更新入会算法,内置船新入会本地算法
|
||||
"""
|
||||
|
||||
import time, requests, sys, re, os, json, random
|
||||
from datetime import datetime
|
||||
from urllib.parse import quote_plus, unquote_plus
|
||||
from functools import partial
|
||||
print = partial(print, flush=True)
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
try:
|
||||
from jd_sign import *
|
||||
except ImportError as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
print("请先运行Faker库依赖一键安装脚本(jd_check_dependent.py),安装jd_sign.so依赖")
|
||||
sys.exit()
|
||||
try:
|
||||
from jdCookie import get_cookies
|
||||
getCk = get_cookies()
|
||||
except:
|
||||
print("请先下载依赖脚本,\n下载链接: https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
|
||||
sys.exit(3)
|
||||
|
||||
redis_url = os.environ.get("redis_url") if os.environ.get("redis_url") else "172.17.0.1"
|
||||
redis_port = os.environ.get("redis_port") if os.environ.get("redis_port") else "6379"
|
||||
redis_pwd = os.environ.get("redis_pwd") if os.environ.get("redis_pwd") else ""
|
||||
jd_joinCommonId = os.environ.get("jd_joinCommonId") if os.environ.get("jd_joinCommonId") else ""
|
||||
inviterUuid = os.environ.get("jd_joinCommon_uuid") if os.environ.get("jd_joinCommon_uuid") else ""
|
||||
|
||||
if not jd_joinCommonId:
|
||||
print("⚠️未发现有效活动变量,退出程序!")
|
||||
sys.exit()
|
||||
# 获取远程remote-redis活动ID
|
||||
if "lzdz1_remote" in jd_joinCommonId:
|
||||
jd_joinCommonId_remote = remote_redis(jd_joinCommonId)
|
||||
jd_joinCommonId = jd_joinCommonId_remote
|
||||
else:
|
||||
if "&" not in jd_joinCommonId:
|
||||
print("⚠️活动变量错误,退出程序!")
|
||||
sys.exit()
|
||||
|
||||
activityId = jd_joinCommonId.split('&')[0]
|
||||
shopId = jd_joinCommonId.split('&')[1]
|
||||
activity_url = f"https://lzdz1-isv.isvjcloud.com/dingzhi/joinCommon/activity/5929859?activityId={activityId}&shareUuid={inviterUuid}&adsource=null&shareuserid4minipg=null&lng=00.000000&lat=00.000000&sid=&un_area=&&shopid={shopId}"
|
||||
print(f"【🛳活动入口】https://lzdz1-isv.isvjcloud.com/dingzhi/joinCommon/activity/5929859?activityId={activityId}")
|
||||
|
||||
def redis_conn():
|
||||
try:
|
||||
import redis
|
||||
try:
|
||||
pool = redis.ConnectionPool(host=redis_url, port=redis_port, decode_responses=True, socket_connect_timeout=5, password=redis_pwd)
|
||||
r = redis.Redis(connection_pool=pool)
|
||||
r.get('conn_test')
|
||||
print('✅redis连接成功')
|
||||
return r
|
||||
except:
|
||||
print("⚠️redis连接异常")
|
||||
except:
|
||||
print("⚠️缺少redis依赖,请运行pip3 install redis")
|
||||
sys.exit()
|
||||
|
||||
def getToken(ck, r=None):
|
||||
host = f'{activityUrl.split("com/")[0]}com'
|
||||
try:
|
||||
pt_pin = unquote_plus(re.compile(r'pt_pin=(.*?);').findall(ck)[0])
|
||||
except:
|
||||
pt_pin = ck[:15]
|
||||
try:
|
||||
try:
|
||||
Token = r.get(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}')
|
||||
except Exception as e:
|
||||
# print(f"redis get error: {str(e)}")
|
||||
Token = None
|
||||
if Token is not None:
|
||||
print(f"♻️获取缓存Token")
|
||||
return Token
|
||||
else:
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign({"url": f"{host}", "id": ""}, 'isvObfuscator')
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
print(f.text)
|
||||
return
|
||||
Token_new = f.json()['token']
|
||||
try:
|
||||
if r.set(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}', Token_new, ex=1800):
|
||||
print("✅Token缓存成功")
|
||||
else:
|
||||
print("❌Token缓存失败")
|
||||
except Exception as e:
|
||||
# print(f"redis set error: {str(e)}")
|
||||
print(f"✅获取实时Token")
|
||||
return Token_new
|
||||
except Exception as e:
|
||||
print(f"Get Token Error: {str(e)}")
|
||||
return
|
||||
|
||||
def getJdTime():
|
||||
jdTime = int(round(time.time() * 1000))
|
||||
return jdTime
|
||||
|
||||
def randomString(e, flag=False):
|
||||
t = "0123456789abcdef"
|
||||
if flag: t = t.upper()
|
||||
n = [random.choice(t) for _ in range(e)]
|
||||
return ''.join(n)
|
||||
|
||||
def refresh_cookies(res):
|
||||
if res.cookies:
|
||||
cookies = res.cookies.get_dict()
|
||||
set_cookie = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
global activityCookie
|
||||
activityCookieMid = [i for i in activityCookie.split(';') if i != '']
|
||||
for i in activityCookieMid:
|
||||
for x in set_cookie:
|
||||
if i.split('=')[0] == x.split('=')[0]:
|
||||
if i.split('=')[1] != x.split('=')[1]:
|
||||
activityCookieMid.remove(i)
|
||||
activityCookie = ''.join(sorted([(set_cookie + ";") for set_cookie in list(set(activityCookieMid + set_cookie))]))
|
||||
|
||||
def getActivity():
|
||||
url = activityUrl
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Connection': 'keep-alive'
|
||||
}
|
||||
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
if response.status_code == 200:
|
||||
if response.cookies:
|
||||
cookies = response.cookies.get_dict()
|
||||
set_cookies = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
set_cookie = ''.join(sorted([(set_cookie + ";") for set_cookie in set_cookies]))
|
||||
return set_cookie
|
||||
else:
|
||||
print(response.status_code, "⚠️ip疑似黑了,休息一会再来撸~")
|
||||
sys.exit()
|
||||
|
||||
def getSystemConfigForNew():
|
||||
url = "https://lzdz1-isv.isvjcloud.com/wxCommonInfo/getSystemConfigForNew"
|
||||
payload = f'activityId={activityId}&activityType=99'
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getSimpleActInfoVo():
|
||||
url = "https://lzdz1-isv.isvjcloud.com/dz/common/getSimpleActInfoVo"
|
||||
payload = f"activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def getMyPing(index, venderId):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/customer/getMyPing"
|
||||
payload = f"userId={venderId}&token={token}&fromType=APP"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']['nickname'], res['data']['secretPin']
|
||||
else:
|
||||
print(f"⚠️{res['errorMessage']}")
|
||||
if index == 1 and "火爆" in res['errorMessage']:
|
||||
print(f"\t⛈车头黑,退出本程序!")
|
||||
sys.exit()
|
||||
|
||||
def accessLogWithAD(venderId, pin):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/common/accessLogWithAD"
|
||||
payload = f"venderId={venderId}&code=99&pin={quote_plus(pin)}&activityId={activityId}&pageUrl={quote_plus(activityUrl)}&subType=app&adSource=null"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getSystime():
|
||||
url = "https://lzdz1-isv.isvjcloud.com/common/getSystime"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Cookie': activityCookie,
|
||||
'Content-Length': '0',
|
||||
'Connection': 'keep-alive',
|
||||
'Accept': 'application/json',
|
||||
'User-Agent': ua,
|
||||
'Referer': activityUrl,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getUserInfo(pin):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/wxActionCommon/getUserInfo"
|
||||
payload = f"pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']['nickname'], res['data']['yunMidImageUrl'], res['data']['pin']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def activityContent(pin, pinImg, nickname):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/dingzhi/joinCommon/activityContent"
|
||||
try:
|
||||
yunMidImageUrl = quote_plus(pinImg)
|
||||
except:
|
||||
yunMidImageUrl = quote_plus("https://img10.360buyimg.com/imgzone/jfs/t1/21383/2/6633/3879/5c5138d8E0967ccf2/91da57c5e2166005.jpg")
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}&pinImg={yunMidImageUrl}&nick={quote_plus(nickname)}&cjyxPin=&cjhyPin=&shareUuid={shareUuid}"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};{activityCookie}'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
if "活动已结束" in res['errorMessage']:
|
||||
sys.exit()
|
||||
|
||||
def shareRecord(pin, actorUuid):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/dingzhi/joinCommon/shareRecord"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}&uuid={actorUuid}&num=30"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def taskRecord(pin, actorUuid):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/dingzhi/joinCommon/taskRecord"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}&uuid={actorUuid}&taskType="
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def drawContent(actorUuid, pin):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/dingzhi/taskact/common/drawContent"
|
||||
payload = f"activityId={actorUuid}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
def taskInfo(pin):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/dingzhi/joinCommon/taskInfo"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def assist(pin, uuid):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/dingzhi/joinCommon/assist"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}&uuid={uuid}&shareUuid={shareUuid}"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def doTask(actorUuid, pin, taskType):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/dingzhi/joinCommon/doTask"
|
||||
payload = f"activityId={activityId}&uuid={actorUuid}&pin={quote_plus(pin)}&taskType={taskType}&taskValue="
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
res = response.json()
|
||||
print('doTask', res)
|
||||
if res['result']:
|
||||
data = res['data']
|
||||
if data['score'] == 0:
|
||||
print("\t获得 💨💨💨")
|
||||
else:
|
||||
print(f"\t🎉获得{data['score']}积分")
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def bindWithVender(cookie, venderId):
|
||||
try:
|
||||
shopcard_url0 = f"https://lzdz1-isv.isvjcloud.com/dingzhi/joinCommon/activity/7854908?activityId={activityId}&shareUuid={shareUuid}"
|
||||
shopcard_url = f"https://shopmember.m.jd.com/shopcard/?venderId={venderId}&channel=401&returnUrl={quote_plus(shopcard_url0)}"
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': ua,
|
||||
'Cookie': cookie,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': 'https://shopmember.m.jd.com/',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
s.params = {
|
||||
'appid': 'jd_shop_member',
|
||||
'functionId': 'bindWithVender',
|
||||
'body': json.dumps({
|
||||
'venderId': venderId,
|
||||
'shopId': venderId,
|
||||
'bindByVerifyCodeFlag': 1
|
||||
}, separators=(',', ':'))
|
||||
}
|
||||
res = s.post('https://api.m.jd.com/', verify=False, timeout=30).json()
|
||||
if res['success']:
|
||||
return res['message']
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def getShopOpenCardInfo(cookie, venderId):
|
||||
try:
|
||||
body = {"venderId": str(venderId), "channel": "401"}
|
||||
url = f'https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body={json.dumps(body)}&client=H5&clientVersion=9.2.0&uuid=88888'
|
||||
headers = {
|
||||
'Host': 'api.m.jd.com',
|
||||
'Accept': '*/*',
|
||||
'Connection': 'keep-alive',
|
||||
'Cookie': cookie,
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-cn',
|
||||
'Referer': 'https://shopmember.m.jd.com/',
|
||||
'Accept-Encoding': 'gzip, deflate'
|
||||
}
|
||||
response = requests.get(url=url, headers=headers, timeout=5).text
|
||||
res = json.loads(response)
|
||||
if res['success']:
|
||||
venderCardName = res['result']['shopMemberCardInfo']['venderCardName']
|
||||
return venderCardName
|
||||
else:
|
||||
return venderId
|
||||
except:
|
||||
return venderId
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = redis_conn()
|
||||
try:
|
||||
cks = getCk
|
||||
if not cks:
|
||||
sys.exit()
|
||||
except:
|
||||
print("未获取到有效COOKIE,退出程序!")
|
||||
sys.exit()
|
||||
global shareUuid, inviteSuccNum, activityUrl, firstCk
|
||||
inviteSuccNum = 0
|
||||
if len(cks) == 1:
|
||||
shareUuid = inviterUuid
|
||||
activityUrl = activity_url
|
||||
else:
|
||||
shareUuid = remote_redis(f"lzdz1_{activityId}", 2)
|
||||
activityUrl = f"https://lzdz1-isv.isvjcloud.com/dingzhi/joinCommon/activity/5929859?activityId={activityId}&shareUuid={shareUuid}&adsource=null&shareuserid4minipg=null&lng=00.000000&lat=00.000000&sid=&un_area=&&shopid={shopId}"
|
||||
num = 0
|
||||
for cookie in cks[:]:
|
||||
num += 1
|
||||
if num == 1:
|
||||
firstCk = cookie
|
||||
if num % 8 == 0:
|
||||
print("⏰等待10s,休息一下")
|
||||
time.sleep(10)
|
||||
global ua, activityCookie, token
|
||||
ua = userAgent()
|
||||
try:
|
||||
pt_pin = re.compile(r'pt_pin=(.*?);').findall(cookie)[0]
|
||||
pt_pin = unquote_plus(pt_pin)
|
||||
except IndexError:
|
||||
pt_pin = re.compile(r'pin=(.*?);').findall(cookie)[0]
|
||||
pt_pin = unquote_plus(pt_pin)
|
||||
print(f'\n******开始【京东账号{num}】{pt_pin} *********\n')
|
||||
print(datetime.now())
|
||||
|
||||
token = getToken(cookie, r)
|
||||
if token is None:
|
||||
if num == 1:
|
||||
print(f"⚠️车头获取Token失败,退出本程序!")
|
||||
sys.exit()
|
||||
print(f"⚠️获取Token失败!⏰等待3s")
|
||||
time.sleep(3)
|
||||
continue
|
||||
time.sleep(0.5)
|
||||
activityCookie = getActivity()
|
||||
time.sleep(0.5)
|
||||
getSystemConfigForNew()
|
||||
time.sleep(0.3)
|
||||
getSimAct = getSimpleActInfoVo()
|
||||
if getSimAct:
|
||||
venderId = getSimAct['venderId']
|
||||
else:
|
||||
venderId = shopId
|
||||
time.sleep(0.2)
|
||||
getPin = getMyPing(num, venderId)
|
||||
if getPin is not None:
|
||||
nickname = getPin[0]
|
||||
secretPin = getPin[1]
|
||||
time.sleep(0.5)
|
||||
accessLogWithAD(venderId, secretPin)
|
||||
time.sleep(0.5)
|
||||
userInfo = getUserInfo(secretPin)
|
||||
time.sleep(0.8)
|
||||
nickname = userInfo[0]
|
||||
yunMidImageUrl = userInfo[1]
|
||||
pin = userInfo[2]
|
||||
actContent = activityContent(pin, yunMidImageUrl, nickname)
|
||||
if not actContent:
|
||||
if num == 1:
|
||||
print("⚠️无法获取车头邀请码,退出本程序!")
|
||||
sys.exit()
|
||||
continue
|
||||
hasEnd = actContent['hasEnd']
|
||||
if hasEnd:
|
||||
print("活动已结束,下次早点来~")
|
||||
sys.exit()
|
||||
print(f"✅开启【{actContent['activityName']}】活动\n")
|
||||
if num == 1:
|
||||
print(f"🛳 已邀请{actContent['actorInfo']['totalAssistCount']}, 有效助力{actContent['actorInfo']['assistCount']}")
|
||||
actorUuid = actContent['actorInfo']['uuid']
|
||||
taskType = actContent['taskType']
|
||||
print(f"邀请码->: {actorUuid}")
|
||||
print(f"准备助力->: {shareUuid}")
|
||||
time.sleep(0.5)
|
||||
shareRecord(pin, actorUuid)
|
||||
time.sleep(0.5)
|
||||
taskRecord(pin, actorUuid)
|
||||
time.sleep(0.5)
|
||||
print("现在去一键关注店铺")
|
||||
doTask(actorUuid, pin, 20)
|
||||
time.sleep(1)
|
||||
doTask(actorUuid, pin, 23)
|
||||
time.sleep(1)
|
||||
ass0 = assist(pin, actorUuid)
|
||||
assistState0 = ass0['assistState']
|
||||
openAll0 = ass0['openCardInfo']['openAll']
|
||||
openVenderId0 = ass0['openCardInfo']['openVenderId']
|
||||
assStat = False
|
||||
if openAll0:
|
||||
print("已完成全部开卡任务")
|
||||
if assistState0 == 0:
|
||||
print("无法助力自己~")
|
||||
elif assistState0 == 3:
|
||||
print("已助力过其他好友~")
|
||||
elif assistState0 == 1:
|
||||
print("已完成开卡关注任务,未助力过好友~")
|
||||
assStat = True
|
||||
else:
|
||||
# print('assistStatus:', assistState0)
|
||||
assStat = True
|
||||
else:
|
||||
print("现在去开卡")
|
||||
task_info0 = taskInfo(pin)
|
||||
openCardList = task_info0['1']['settingInfo']
|
||||
openCardLists = [(int(i['value']), i['name']) for i in openCardList]
|
||||
unOpenCardLists = [i for i in openCardLists if i[0] not in openVenderId0]
|
||||
for shop in unOpenCardLists:
|
||||
print(f"去开卡 {shop[1]} {shop[0]}")
|
||||
venderId = shop[0]
|
||||
venderCardName = shop[1]
|
||||
getShopOpenCardInfo(cookie, venderId)
|
||||
open_result = bindWithVender(cookie, venderId)
|
||||
if open_result is not None:
|
||||
if "火爆" in open_result or "失败" in open_result or "解绑" in open_result:
|
||||
print(f"\t⛈⛈{venderCardName} {open_result}")
|
||||
assStat = False
|
||||
break
|
||||
else:
|
||||
print(f"\t🎉🎉{venderCardName} {open_result}")
|
||||
assStat = True
|
||||
time.sleep(1.5)
|
||||
activityContent(pin, yunMidImageUrl, nickname)
|
||||
shareRecord(pin, actorUuid)
|
||||
time.sleep(0.5)
|
||||
taskRecord(pin, actorUuid)
|
||||
time.sleep(0.5)
|
||||
ass1 = assist(pin, actorUuid)
|
||||
assistState1 = ass1['assistState']
|
||||
if assStat and assistState1 == 1:
|
||||
print("🎉🎉🎉助力成功~")
|
||||
if num != 1:
|
||||
inviteSuccNum += 1
|
||||
print(f"本次车头已邀请{inviteSuccNum}人")
|
||||
elif assStat and assistState0 == 1:
|
||||
print("🎉🎉🎉助力成功~")
|
||||
if num != 1:
|
||||
inviteSuccNum += 1
|
||||
print(f"本次车头已邀请{inviteSuccNum}人")
|
||||
|
||||
if num == 1:
|
||||
print(f"后面账号全部助力 {actorUuid}")
|
||||
shareUuid = actorUuid
|
||||
activityUrl = f"https://lzdz1-isv.isvjcloud.com/dingzhi/joinCommon/activity/5929859?activityId={activityId}&shareUuid={shareUuid}&adsource=null&shareuserid4minipg=null&lng=00.000000&lat=00.000000&sid=&un_area=&&shopid={shopId}"
|
||||
|
||||
time.sleep(3)
|
@ -1,642 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
File: jd_lzkjInteract.py(jd_lzkjInteract邀请有礼)
|
||||
Author: HarbourJ
|
||||
Date: 2022/11/24 10:00
|
||||
TG: https://t.me/HarbourToulu
|
||||
TgChat: https://t.me/HarbourChat
|
||||
cron: 1 1 1 1 1 1
|
||||
new Env('jd_lzkjInteract邀请有礼');
|
||||
ActivityEntry: https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=10006&activityId=1595256546199793665&templateId=20201228083300yqrhyl011&nodeId=101001005&prd=cjwx
|
||||
|
||||
Description: 邀请xx人xx豆,自动助力,自动领奖
|
||||
"""
|
||||
|
||||
import time, requests, sys, re, os, json, random
|
||||
from datetime import datetime
|
||||
from urllib.parse import quote_plus, unquote_plus
|
||||
from functools import partial
|
||||
from sendNotify import *
|
||||
print = partial(print, flush=True)
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
try:
|
||||
from jd_sign import *
|
||||
except ImportError as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
print("请先运行Faker库依赖一键安装脚本(jd_check_dependent.py),安装jd_sign.so依赖")
|
||||
try:
|
||||
from jdCookie import get_cookies
|
||||
getCk = get_cookies()
|
||||
except:
|
||||
print("请先下载依赖脚本,\n下载链接: https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
|
||||
sys.exit(3)
|
||||
|
||||
redis_url = os.environ.get("redis_url") if os.environ.get("redis_url") else "172.17.0.1"
|
||||
redis_port = os.environ.get("redis_port") if os.environ.get("redis_port") else "6379"
|
||||
redis_pwd = os.environ.get("redis_pwd") if os.environ.get("redis_pwd") else ""
|
||||
jd_lzkjInteractUrl = os.environ.get("jd_lzkjInteractUrl") if os.environ.get("jd_lzkjInteractUrl") else ""
|
||||
share_userId = os.environ.get("jd_lzkjInteractUserId") if os.environ.get("jd_lzkjInteractUserId") else ""
|
||||
|
||||
if "lzkj-isv.isvjcloud.com/prod/cc/interactsaas" not in jd_lzkjInteractUrl:
|
||||
print("⛈暂不支持变量设置的活动类型,请检查后重试!仅支持interactsaas类型活动")
|
||||
sys.exit()
|
||||
templateId = re.findall(r"templateId=(.*?)&", jd_lzkjInteractUrl+"&")[0]
|
||||
activityId = re.findall(r"activityId=(.*?)&", jd_lzkjInteractUrl+"&")[0]
|
||||
activityType = re.findall(r"activityType=(.*?)&", jd_lzkjInteractUrl+"&")[0]
|
||||
|
||||
activity_url = f"https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType={activityType}&activityId={activityId}&shareUserId={share_userId}&templateId={templateId}&prd=null&sid=c77e8b335974724742827d7c42f951cw&un_area=12_1212_11111_22222"
|
||||
|
||||
print(f"【🛳活动入口】https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType={activityType}&templateId={templateId}&activityId={activityId}")
|
||||
|
||||
def redis_conn():
|
||||
try:
|
||||
import redis
|
||||
try:
|
||||
pool = redis.ConnectionPool(host=redis_url, port=6379, decode_responses=True, socket_connect_timeout=5, password=redis_pwd)
|
||||
r = redis.Redis(connection_pool=pool)
|
||||
r.get('conn_test')
|
||||
print('✅redis连接成功')
|
||||
return r
|
||||
except:
|
||||
print("⚠️redis连接异常")
|
||||
except:
|
||||
print("⚠️缺少redis依赖,请运行pip3 install redis")
|
||||
sys.exit()
|
||||
|
||||
def getToken(ck, r=None):
|
||||
host = f'{activityUrl.split("com/")[0]}com'
|
||||
try:
|
||||
pt_pin = unquote_plus(re.compile(r'pt_pin=(.*?);').findall(ck)[0])
|
||||
except:
|
||||
pt_pin = ck[:15]
|
||||
try:
|
||||
try:
|
||||
Token = r.get(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}')
|
||||
except Exception as e:
|
||||
Token = None
|
||||
if Token is not None:
|
||||
print(f"♻️获取缓存Token")
|
||||
return Token
|
||||
else:
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign({"url": f"{host}", "id": ""}, 'isvObfuscator')
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
print(f.text)
|
||||
return
|
||||
Token_new = f.json()['token']
|
||||
try:
|
||||
if r.set(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}', Token_new, ex=1800):
|
||||
print("✅Token缓存成功")
|
||||
else:
|
||||
print("❌Token缓存失败")
|
||||
except Exception as e:
|
||||
print(f"✅获取实时Token")
|
||||
return Token_new
|
||||
except Exception as e:
|
||||
print(f"Token error: {str(e)}")
|
||||
return
|
||||
|
||||
def getJdTime():
|
||||
jdTime = int(round(time.time() * 1000))
|
||||
return jdTime
|
||||
|
||||
def randomString(e, flag=False):
|
||||
t = "0123456789abcdef"
|
||||
if flag: t = t.upper()
|
||||
n = [random.choice(t) for _ in range(e)]
|
||||
return ''.join(n)
|
||||
|
||||
def check(ck):
|
||||
try:
|
||||
url = 'https://me-api.jd.com/user_new/info/GetJDUserInfoUnion'
|
||||
header = {
|
||||
"Host": "me-api.jd.com",
|
||||
"Accept": "*/*",
|
||||
"Connection": "keep-alive",
|
||||
"Cookie": ck,
|
||||
"User-Agent": ua,
|
||||
"Accept-Language": "zh-cn",
|
||||
"Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&",
|
||||
"Accept-Encoding": "gzip, deflate",
|
||||
}
|
||||
result = requests.get(url=url, headers=header).text
|
||||
codestate = json.loads(result)
|
||||
if codestate['retcode'] == '1001':
|
||||
msg = "当前ck已失效,请检查"
|
||||
return {'code': 1001, 'data': msg}
|
||||
elif codestate['retcode'] == '0' and 'userInfo' in codestate['data']:
|
||||
nickName = codestate['data']['userInfo']['baseInfo']['nickname']
|
||||
return {'code': 200, 'name': nickName, 'ck': cookie}
|
||||
except Exception as e:
|
||||
return {'code': 0, 'data': e}
|
||||
|
||||
def getActivity():
|
||||
url = activityUrl
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Connection': 'keep-alive'
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
if response.status_code != 200:
|
||||
print(response.status_code, "⚠️ip疑似黑了,休息一会再来撸~")
|
||||
sys.exit()
|
||||
|
||||
def followShop(Token):
|
||||
url = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/api/task/followShop/follow"
|
||||
body = {}
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'token': Token,
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl
|
||||
}
|
||||
response = requests.post(url, headers=headers, data=json.dumps(body))
|
||||
try:
|
||||
return response.json()
|
||||
except:
|
||||
return False
|
||||
|
||||
def getUserInfo(shareUserId):
|
||||
url = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/api/user-info/login"
|
||||
body = {
|
||||
"status": "0",
|
||||
"activityId": activityId,
|
||||
"source": "01",
|
||||
"tokenPin": token,
|
||||
"shareUserId": shareUserId
|
||||
}
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'token': '',
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=json.dumps(body))
|
||||
if response.status_code == 200:
|
||||
res = response.json()
|
||||
if res['data']:
|
||||
return res['data']
|
||||
else:
|
||||
print(res)
|
||||
else:
|
||||
print(response.status_code, "⚠️ip疑似黑了,休息一会再来撸~")
|
||||
sys.exit()
|
||||
|
||||
def guestMyself(Token, shareUserId):
|
||||
url = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/api/task/bargain/guest/myself"
|
||||
body = {
|
||||
"shareUserId": shareUserId
|
||||
}
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'token': Token,
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl
|
||||
}
|
||||
requests.post(url, headers=headers, data=json.dumps(body))
|
||||
|
||||
def getMember(Token, shareUserId):
|
||||
url = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/api/task/member/getMember"
|
||||
body = {
|
||||
"shareUserId": shareUserId
|
||||
}
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'token': Token,
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl
|
||||
}
|
||||
response = requests.post(url, headers=headers, data=json.dumps(body))
|
||||
try:
|
||||
res = response.json()
|
||||
inviteNum = res['data']['shareUser']
|
||||
return inviteNum
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
return False
|
||||
|
||||
def prizeList(Token):
|
||||
url = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/api/task/member/prizeList"
|
||||
body = {}
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'token': Token,
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl
|
||||
}
|
||||
response = requests.post(url, headers=headers, data=json.dumps(body))
|
||||
try:
|
||||
return response.json()
|
||||
except:
|
||||
return False
|
||||
|
||||
def joinCheck(Token):
|
||||
url = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/api/join/check"
|
||||
body = {
|
||||
"status": "0"
|
||||
}
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'token': Token,
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl
|
||||
}
|
||||
response = requests.post(url, headers=headers, data=json.dumps(body))
|
||||
try:
|
||||
return response.json()
|
||||
except:
|
||||
return False
|
||||
|
||||
def getUserId(Token):
|
||||
url = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/api/task/share/getUserId"
|
||||
body = {}
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'token': Token,
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl
|
||||
}
|
||||
response = requests.post(url, headers=headers, data=json.dumps(body))
|
||||
try:
|
||||
return response.json()['data']['shareUserId']
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
def receiveAcquire(Token, id):
|
||||
url = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/api/prize/receive/acquire"
|
||||
body = {
|
||||
"prizeInfoId": id,
|
||||
"status": 1
|
||||
}
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'token': Token,
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl
|
||||
}
|
||||
response = requests.post(url, headers=headers, data=json.dumps(body))
|
||||
try:
|
||||
return response.json()['resp_code']
|
||||
except:
|
||||
print(response.text)
|
||||
return False
|
||||
|
||||
def bindWithVender(cookie, shopId, venderId):
|
||||
try:
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': ua,
|
||||
'Cookie': cookie,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': 'https://shopmember.m.jd.com/',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
s.params = {
|
||||
'appid': 'jd_shop_member',
|
||||
'functionId': 'bindWithVender',
|
||||
'body': json.dumps({
|
||||
'venderId': venderId,
|
||||
'shopId': shopId,
|
||||
'bindByVerifyCodeFlag': 1
|
||||
}, separators=(',', ':'))
|
||||
}
|
||||
res = s.post('https://api.m.jd.com/', verify=False, timeout=30).json()
|
||||
if res['success']:
|
||||
return res['message']
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def getShopOpenCardInfo(cookie, venderId):
|
||||
shopcard_url = f"https://shopmember.m.jd.com/shopcard/?venderId={venderId}&channel=401&returnUrl={quote_plus(activityUrl)}"
|
||||
try:
|
||||
body = {"venderId": str(venderId), "channel": "8019006"}
|
||||
url = f'https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body={json.dumps(body)}&client=H5&clientVersion=9.2.0&uuid=88888'
|
||||
headers = {
|
||||
'Host': 'api.m.jd.com',
|
||||
'Accept': '*/*',
|
||||
'Connection': 'keep-alive',
|
||||
'Cookie': cookie,
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-cn',
|
||||
'Referer': shopcard_url,
|
||||
'Accept-Encoding': 'gzip, deflate'
|
||||
}
|
||||
response = requests.get(url=url, headers=headers, timeout=5).text
|
||||
res = json.loads(response)
|
||||
if res['success']:
|
||||
venderCardName = res['result']['shopMemberCardInfo']['venderCardName']
|
||||
openCardStatus = res['result']['userInfo']['openCardStatus']
|
||||
return venderCardName, openCardStatus
|
||||
else:
|
||||
return False, 1
|
||||
except:
|
||||
return False, 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = redis_conn()
|
||||
try:
|
||||
cks = getCk
|
||||
if not cks:
|
||||
sys.exit()
|
||||
except:
|
||||
print("未获取到有效COOKIE,退出程序!")
|
||||
sys.exit()
|
||||
global shareUserId, inviteSuccNum, activityUrl, firstCk, MSG
|
||||
inviteSuccNum = 0
|
||||
MSG = ''
|
||||
title = "🗣消息提醒:lzkjInteract邀请有礼"
|
||||
if len(cks) == 1:
|
||||
shareUserId = share_userId
|
||||
activityUrl = activity_url
|
||||
else:
|
||||
try:
|
||||
shareUserId = remote_redis(f"lzkj_{activityId}", 2)
|
||||
shareUserId = shareUserId if shareUserId else ""
|
||||
except:
|
||||
shareUserId = ""
|
||||
activityUrl = f"https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType={activityType}&templateId={templateId}&activityId={activityId}&shareUserId={shareUserId}&prd=null&sid=c77e8b335974724742827d7c42f951cw&un_area=12_1212_11111_22222"
|
||||
num = 0
|
||||
for cookie in cks[:]:
|
||||
num += 1
|
||||
if num == 1:
|
||||
firstCk = cookie
|
||||
if num % 5 == 0:
|
||||
print("⏰等待5s,休息一下")
|
||||
time.sleep(5)
|
||||
global ua, token
|
||||
ua = userAgent()
|
||||
try:
|
||||
pt_pin = re.compile(r'pt_pin=(.*?);').findall(cookie)[0]
|
||||
pt_pin = unquote_plus(pt_pin)
|
||||
except IndexError:
|
||||
pt_pin = f'用户{num}'
|
||||
print(f'\n******开始【京东账号{num}】{pt_pin} *********\n')
|
||||
print(datetime.now())
|
||||
|
||||
result = check(cookie)
|
||||
if result['code'] != 200:
|
||||
if num == 1:
|
||||
print("⚠️车头CK失效,退出程序!")
|
||||
sys.exit()
|
||||
print(f"⚠️当前CK失效!跳过")
|
||||
continue
|
||||
token = getToken(cookie, r)
|
||||
if token is None:
|
||||
if num == 1:
|
||||
print(f"⚠️车头获取Token失败,退出本程序!")
|
||||
sys.exit()
|
||||
print(f"⚠️获取Token失败!⏰等待3s")
|
||||
time.sleep(3)
|
||||
continue
|
||||
time.sleep(0.5)
|
||||
getActivity()
|
||||
time.sleep(0.5)
|
||||
userInfo = getUserInfo(shareUserId)
|
||||
if not userInfo:
|
||||
if num == 1:
|
||||
print('⚠️无法获取userInfo,退出本程序!')
|
||||
sys.exit()
|
||||
time.sleep(2)
|
||||
continue
|
||||
shopId = userInfo['shopId']
|
||||
openCardUrl = userInfo['joinInfo']['openCardUrl']
|
||||
venderId = re.findall(r"venderId=(\w+)", openCardUrl)
|
||||
venderId = venderId[0] if venderId else ""
|
||||
Token = userInfo['token']
|
||||
shopName = userInfo['shopName']
|
||||
actName = userInfo['actName']
|
||||
joinCodeInfo = userInfo['joinInfo']['joinCodeInfo']
|
||||
customerId = userInfo['customerId']
|
||||
time.sleep(0.3)
|
||||
followShop(Token)
|
||||
time.sleep(0.3)
|
||||
guestMyself(Token, shareUserId)
|
||||
time.sleep(0.3)
|
||||
|
||||
if num == 1:
|
||||
print(f"✅ 开启【{actName}】活动")
|
||||
print(f"店铺名称:{shopName} {shopId}")
|
||||
MSG += f'✅账号[{pt_pin}] 开启{actName}活动\n📝活动地址 {activityUrl.split("&shareUserId=")[0]}\n'
|
||||
if shareUserId:
|
||||
print(f"CK1准备助力【{shareUserId}】")
|
||||
else:
|
||||
print(f"未填写助力码,CK1准备助力💨")
|
||||
if "不是会员无法参加" not in joinCodeInfo['joinDes']:
|
||||
print("已经是会员,助力失败!")
|
||||
joinCheck(Token)
|
||||
time.sleep(0.2)
|
||||
inviteNum = getMember(Token, shareUserId)
|
||||
time.sleep(0.2)
|
||||
inviteSuccNum = inviteNum # 接口显示已邀请人数
|
||||
print(f"🧑🤝🧑 CK1已邀请{inviteNum}人\n")
|
||||
time.sleep(0.2)
|
||||
prizeListResponse = prizeList(Token)
|
||||
prizeListRecord = []
|
||||
prizeNameList = []
|
||||
index = 0
|
||||
try:
|
||||
for prizeitem in prizeListResponse['data']['prizeInfo']:
|
||||
index += 1
|
||||
print(f"🎁 奖品: {prizeitem['prizeName']}, 助力人数: {prizeitem['days']}, 总数:{prizeitem['allNum']}, 剩余:{prizeitem['leftNum']}, ID: {prizeitem['id']}")
|
||||
prizeNameList.append(f"🎁奖品:{prizeitem['prizeName']},助力人数:{prizeitem['days']},总数:{prizeitem['allNum']},剩余:{prizeitem['leftNum']}\n")
|
||||
if prizeitem['leftNum'] > 0:
|
||||
prizeListRecord.append((prizeitem['prizeName'], prizeitem['days'], prizeitem['id']))
|
||||
MSG += f"🎁当前活动奖品如下: \n{str(''.join(prizeNameList))}\n"
|
||||
except:
|
||||
print('⚠️无法获取奖品列表, 退出本程序!')
|
||||
sys.exit()
|
||||
if prizeListRecord == []:
|
||||
print('⚠️无奖品可领,退出本程序!')
|
||||
sys.exit()
|
||||
for prizeinfo in prizeListRecord:
|
||||
if inviteSuccNum >= prizeinfo[1]:
|
||||
print(f'已达到领取条件,开始领取 {prizeinfo[0]}')
|
||||
receive_result = receiveAcquire(Token, prizeinfo[2])
|
||||
if receive_result == 0:
|
||||
print(f'🎉🎉 领取奖励成功')
|
||||
MSG += f"🎉成功领取 {prizeinfo[0]}\n"
|
||||
elif receive_result == 60002:
|
||||
print(f'🎉🎉 奖励已经领取过')
|
||||
MSG += f"🎉已经领取过 {prizeinfo[0]}\n"
|
||||
elif receive_result == 60009:
|
||||
print(f'🎉🎉 奖励已经领取过其他奖励或未达到领取标准建议手动领取!')
|
||||
MSG += f"🎉奖励已经领取过其他奖励或未达到领取标准建议手动领取 {prizeinfo[0]}\n"
|
||||
else:
|
||||
print(f'💥💥 领取奖励失败')
|
||||
MSG += f"💥💥 领取奖励失败 {prizeinfo[0]}\n"
|
||||
time.sleep(1.5)
|
||||
if inviteSuccNum >= prizeListRecord[-1][1]:
|
||||
print("奖励已领完")
|
||||
MSG += f"🤖奖励已领完\n"
|
||||
if len(cks) > 1:
|
||||
send(title, MSG)
|
||||
sys.exit()
|
||||
actorUuid = getUserId(Token)
|
||||
time.sleep(0.3)
|
||||
if not actorUuid:
|
||||
if num == 1:
|
||||
print(f'⚠️ 无法获取车头邀请码, 退出本程序!')
|
||||
sys.exit()
|
||||
print(f"\n后面账号全部助力 {actorUuid}")
|
||||
shareUserId = actorUuid
|
||||
activityUrl = f"https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType={activityType}&templateId={templateId}&activityId={activityId}&shareUserId={shareUserId}&prd=null&sid=c77e8b335974724742827d7c42f951cw&un_area=12_1212_11111_22222"
|
||||
continue
|
||||
else:
|
||||
inviteSuccNum = 0
|
||||
|
||||
if "不是会员无法参加" in joinCodeInfo['joinDes']:
|
||||
print(f"未开卡 现在去开卡")
|
||||
open_result = bindWithVender(cookie, shopId, venderId)
|
||||
if open_result is not None:
|
||||
if "火爆" in open_result or "失败" in open_result or "解绑" in open_result:
|
||||
print(f"\t💥💥 {open_result}\n‼️助力失败")
|
||||
continue
|
||||
else:
|
||||
print(f"\t🎉🎉 {open_result}")
|
||||
if num != 1:
|
||||
inviteSuccNum += 1
|
||||
print(f"🛳已经邀请{inviteSuccNum}人")
|
||||
time.sleep(0.3)
|
||||
joinCheck(Token)
|
||||
time.sleep(0.3)
|
||||
getMember(Token, shareUserId)
|
||||
time.sleep(0.3)
|
||||
prizeListResponse = prizeList(Token)
|
||||
prizeListRecord = []
|
||||
prizeNameList = []
|
||||
index = 0
|
||||
try:
|
||||
for prizeitem in prizeListResponse['data']['prizeInfo']:
|
||||
index += 1
|
||||
if num == 1:
|
||||
print(f"🎁 奖品: {prizeitem['prizeName']}, 助力人数: {prizeitem['days']}, 总数:{prizeitem['allNum']}, 剩余:{prizeitem['leftNum']}, ID: {prizeitem['id']}")
|
||||
prizeNameList.append(f"🎁奖品:{prizeitem['prizeName']},助力人数:{prizeitem['days']},总数:{prizeitem['allNum']},剩余:{prizeitem['leftNum']}\n")
|
||||
if prizeitem['leftNum'] > 0:
|
||||
prizeListRecord.append((prizeitem['prizeName'], prizeitem['days'], prizeitem['id']))
|
||||
if prizeNameList:
|
||||
MSG += f"🎁当前活动奖品如下: \n{str(''.join(prizeNameList))}\n"
|
||||
print(f"‼️该活动部分有且仅能领取一次奖励,默认自动领最高档豆🎁,或者手动领取\n")
|
||||
except:
|
||||
print('⚠️无法获取奖品列表, 退出本程序!')
|
||||
sys.exit()
|
||||
if prizeListRecord == []:
|
||||
print('⚠️无奖品可领, 退出本程序!')
|
||||
sys.exit()
|
||||
for prizeinfo in prizeListRecord[:]:
|
||||
if inviteSuccNum == prizeinfo[1]:
|
||||
print(f'CK1已达到领取条件, 开始领取 {prizeinfo[0]}')
|
||||
time.sleep(0.2)
|
||||
token = getToken(firstCk, r)
|
||||
time.sleep(0.2)
|
||||
getActivity()
|
||||
time.sleep(0.2)
|
||||
Token0 = getUserInfo(shareUserId)['token']
|
||||
receive_result = receiveAcquire(Token0, prizeinfo[2])
|
||||
if receive_result == 0:
|
||||
print(f'🎉🎉 领取奖励成功')
|
||||
MSG += f"🎉成功领取 {prizeinfo[0]}\n"
|
||||
elif receive_result == 60002:
|
||||
print(f'🎉🎉 奖励已经领取过')
|
||||
MSG += f"🎉已经领取过 {prizeinfo[0]}\n"
|
||||
elif receive_result == 60009:
|
||||
print(f'🎉🎉 奖励已经领取过其他奖励或未达到领取标准建议手动领取!')
|
||||
MSG += f"🎉奖励已经领取过其他奖励或未达到领取标准建议手动领取 {prizeinfo[0]}\n"
|
||||
else:
|
||||
print(f'💥💥 领取奖励失败')
|
||||
MSG += f"💥💥 领取奖励失败 {prizeinfo[0]}\n"
|
||||
time.sleep(1.5)
|
||||
if inviteSuccNum >= prizeListRecord[-1][1]:
|
||||
print("🤖奖励已领完")
|
||||
MSG += f"🤖奖励已领完\n"
|
||||
if len(cks) > 1:
|
||||
send(title, MSG)
|
||||
sys.exit()
|
||||
time.sleep(0.3)
|
||||
if num == 1:
|
||||
actorUuid = getUserId(Token)
|
||||
if not actorUuid:
|
||||
print(f'⚠️无法获取车头邀请码, 退出本程序!')
|
||||
sys.exit()
|
||||
print(f"后面账号全部助力 {actorUuid}")
|
||||
shareUserId = actorUuid
|
||||
activityUrl = f"https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType={activityType}&templateId={templateId}&activityId={activityId}&shareUserId={shareUserId}&prd=null&sid=c77e8b335974724742827d7c42f951cw&un_area=12_1212_11111_22222"
|
||||
else:
|
||||
print(f"⛈已开卡,无法完成助力")
|
||||
|
||||
time.sleep(2)
|
@ -1,124 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
File: jd_shopCollectGift.py(店铺会员礼包-监控脚本)
|
||||
Author: HarbourJ
|
||||
Date: 2022/9/2 12:00
|
||||
TG: https://t.me/HarbourToulu
|
||||
TgChat: https://t.me/HarbourSailing
|
||||
cron: 1 1 1 1 1 1
|
||||
new Env('店铺会员礼包-JK');
|
||||
ActivityEntry: https://shop.m.jd.com/shop/home?shopId=1000003443
|
||||
Description: 部分账号开卡后无法自动领取开卡奖励,不自动开卡,仅领取已开卡的会员礼包
|
||||
变量export jd_shopCollectGiftId="1000003443" 变量为店铺venderId
|
||||
"""
|
||||
|
||||
import requests, sys, os, re, time
|
||||
from datetime import datetime
|
||||
from functools import partial
|
||||
print = partial(print, flush=True)
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
from urllib.parse import quote_plus, unquote_plus
|
||||
try:
|
||||
from jd_sign import *
|
||||
except ImportError as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
print("请先运行Faker库依赖一键安装脚本(jd_check_dependent.py),安装jd_sign.so依赖")
|
||||
try:
|
||||
from jdCookie import get_cookies
|
||||
getCk = get_cookies()
|
||||
except:
|
||||
print("请先下载依赖脚本,\n下载链接: https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
|
||||
sys.exit(3)
|
||||
|
||||
venderId = os.environ.get("jd_shopCollectGiftId") if os.environ.get("jd_shopCollectGiftId") else ""
|
||||
|
||||
if not venderId:
|
||||
print("⚠️未发现有效活动变量,退出程序!")
|
||||
sys.exit()
|
||||
|
||||
def collectGift(venderId, activityId, activityType, cookie):
|
||||
url = f"https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=collectGift&body=%7B%22venderId%22%3A%22{venderId}%22%2C%22activityId%22%3A{activityId}%2C%22activityType%22%3A{activityType}%7D&clientVersion=9.2.0&client=H5&uuid=88888"
|
||||
headers = {
|
||||
'Host': 'api.m.jd.com',
|
||||
'Accept': '*/*',
|
||||
'Connection': 'keep-alive',
|
||||
'Cookie': cookie,
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Referer': 'https://shopmember.m.jd.com/',
|
||||
'Accept-Encoding': 'gzip, deflate, br'
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
res = response.json()
|
||||
if res['success']:
|
||||
return res['message']
|
||||
else:
|
||||
print(res)
|
||||
|
||||
def getFansDetail(venderId, cookie):
|
||||
url = f"https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getFansFuseMemberDetail&clientVersion=9.2.0&client=H5&uuid=88888&body=%7B%22venderId%22%3A%22{venderId}%22%2C%22channel%22%3A406%2C%22queryVersion%22%3A%2210.5.2%22%7D"
|
||||
headers = {
|
||||
'Host': 'api.m.jd.com',
|
||||
'Accept': '*/*',
|
||||
'Connection': 'keep-alive',
|
||||
'Cookie': cookie,
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Referer': 'https://shopmember.m.jd.com/',
|
||||
'Accept-Encoding': 'gzip, deflate, br'
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
res = response.json()
|
||||
if res['success']:
|
||||
brandName = res['data'][0]['cardInfo']['brandName']
|
||||
if 'newGiftList' in str(res) and res['data'][0]['newGiftList']:
|
||||
activityId = res['data'][0]['newGiftList'][0]['activityId']
|
||||
activityType = res['data'][0]['newGiftList'][0]['activityType']
|
||||
prizeTypeName = res['data'][0]['newGiftList'][0]['prizeTypeName']
|
||||
discount = res['data'][0]['newGiftList'][0]['discount']
|
||||
return activityId, activityType, discount, prizeTypeName, brandName
|
||||
else:
|
||||
print(f"{brandName} 未发现店铺礼包💨")
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
cks = getCk
|
||||
if not cks:
|
||||
sys.exit()
|
||||
except:
|
||||
print("未获取到有效COOKIE,退出程序!")
|
||||
sys.exit()
|
||||
num = 0
|
||||
for cookie in cks[:]:
|
||||
num += 1
|
||||
global ua
|
||||
ua = userAgent()
|
||||
try:
|
||||
pt_pin = re.compile(r'pt_pin=(.*?);').findall(cookie)[0]
|
||||
pt_pin = unquote_plus(pt_pin)
|
||||
except IndexError:
|
||||
pt_pin = f'用户{num}'
|
||||
print(f'\n******开始【京东账号{num}】{pt_pin} *********\n')
|
||||
print(datetime.now())
|
||||
|
||||
try:
|
||||
getFD = getFansDetail(venderId, cookie)
|
||||
if getFD:
|
||||
activityId = getFD[0]
|
||||
activityType = getFD[1]
|
||||
discount = getFD[2]
|
||||
prizeTypeName = getFD[3]
|
||||
brandName = getFD[4]
|
||||
cg = collectGift(venderId, activityId, activityType, cookie)
|
||||
if cg:
|
||||
if "领取成功" in cg:
|
||||
print(f"🎉🎉🎉{brandName} {discount}{prizeTypeName} {cg}")
|
||||
else:
|
||||
print(brandName, cg)
|
||||
except:
|
||||
continue
|
||||
time.sleep(0.5)
|
@ -1,670 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
File: jd_shopLeague_opencard.py(通用开卡-超店shopLeague系列)
|
||||
Author: HarbourJ
|
||||
Date: 2022/8/12 20:37
|
||||
TG: https://t.me/HarbourToulu
|
||||
TgChat: https://t.me/HarbourSailing
|
||||
cron: 1 1 1 1 1 1
|
||||
new Env('通用开卡-超店shopLeague系列');
|
||||
ActivityEntry: https://lzdz1-isv.isvjd.com/dingzhi/shop/league/activity?activityId=dzd16c3e4a819a0e14026da9shop
|
||||
Description: dingzhi/shop/league系列通用开卡脚本(通常情况下,开一张卡5,最高获得220豆,邀请成功获得20豆)。
|
||||
本地sign算法+redis缓存Token
|
||||
变量: export jd_shopLeagueId="2b870a1a7450xxxxxxxxxxxxx" 变量值需要传入活动id
|
||||
并发变量:export jd_shopLeague_uuid="你的shareUuid"
|
||||
Update: 2022/11/01 更新入会算法,内置船新入会本地算法
|
||||
"""
|
||||
|
||||
import time, requests, sys, re, os, json, random
|
||||
from datetime import datetime
|
||||
from urllib.parse import quote_plus, unquote_plus
|
||||
from functools import partial
|
||||
print = partial(print, flush=True)
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
|
||||
try:
|
||||
from jd_sign import *
|
||||
except ImportError as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
print("请先运行Faker库依赖一键安装脚本(jd_check_sign.py),安装jd_sign.so依赖")
|
||||
sys.exit()
|
||||
try:
|
||||
from jdCookie import get_cookies
|
||||
getCk = get_cookies()
|
||||
except:
|
||||
print("请先下载依赖脚本,\n下载链接: https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
|
||||
sys.exit(3)
|
||||
|
||||
redis_url = os.environ.get("redis_url") if os.environ.get("redis_url") else "172.17.0.1"
|
||||
redis_port = os.environ.get("redis_port") if os.environ.get("redis_port") else "6379"
|
||||
redis_pwd = os.environ.get("redis_pwd") if os.environ.get("redis_pwd") else ""
|
||||
jd_shopLeagueId = os.environ.get("jd_shopLeagueId") if os.environ.get("jd_shopLeagueId") else ""
|
||||
inviterUuid = os.environ.get("jd_shopLeague_uuid") if os.environ.get("jd_shopLeague_uuid") else ""
|
||||
|
||||
if not jd_shopLeagueId:
|
||||
print("⚠️未发现有效超店活动变量jd_shopLeagueId,退出程序!")
|
||||
sys.exit()
|
||||
# 获取远程remote-redis活动ID
|
||||
if "lzdz1_remote" in jd_shopLeagueId:
|
||||
jd_jd_shopLeagueId_remote = remote_redis(jd_shopLeagueId)
|
||||
jd_shopLeagueId = jd_jd_shopLeagueId_remote
|
||||
else:
|
||||
if not jd_shopLeagueId:
|
||||
print("⚠️活动变量错误,退出程序!")
|
||||
sys.exit()
|
||||
|
||||
activityId = jd_shopLeagueId.split('&')[0]
|
||||
activity_url = f"https://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/activity/5929859?activityId={activityId}&shareUuid={inviterUuid}"
|
||||
print(f"【🛳活动入口】https://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/activity/5929859?activityId={activityId}")
|
||||
|
||||
def redis_conn():
|
||||
try:
|
||||
import redis
|
||||
try:
|
||||
pool = redis.ConnectionPool(host=redis_url, port=redis_port, decode_responses=True, socket_connect_timeout=5, password=redis_pwd)
|
||||
r = redis.Redis(connection_pool=pool)
|
||||
r.get('conn_test')
|
||||
print('✅redis连接成功')
|
||||
return r
|
||||
except:
|
||||
print("⚠️redis连接异常")
|
||||
except:
|
||||
print("⚠️缺少redis依赖,请运行pip3 install redis")
|
||||
sys.exit()
|
||||
|
||||
def getToken(ck, r=None):
|
||||
host = f'{activityUrl.split("com/")[0]}com'
|
||||
try:
|
||||
pt_pin = unquote_plus(re.compile(r'pt_pin=(.*?);').findall(ck)[0])
|
||||
except:
|
||||
pt_pin = ck[:15]
|
||||
try:
|
||||
try:
|
||||
Token = r.get(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}')
|
||||
except Exception as e:
|
||||
# print(f"redis get error: {str(e)}")
|
||||
Token = None
|
||||
if Token is not None:
|
||||
print(f"♻️获取缓存Token")
|
||||
return Token
|
||||
else:
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign({"url": f"{host}", "id": ""}, 'isvObfuscator')
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
print(f.text)
|
||||
return
|
||||
Token_new = f.json()['token']
|
||||
try:
|
||||
if r.set(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}', Token_new, ex=1800):
|
||||
print("✅Token缓存成功")
|
||||
else:
|
||||
print("❌Token缓存失败")
|
||||
except Exception as e:
|
||||
# print(f"redis set error: {str(e)}")
|
||||
print(f"✅获取实时Token")
|
||||
return Token_new
|
||||
except Exception as e:
|
||||
print(f"Get Token Error: {str(e)}")
|
||||
return
|
||||
|
||||
def getJdTime():
|
||||
jdTime = int(round(time.time() * 1000))
|
||||
return jdTime
|
||||
|
||||
def randomString(e, flag=False):
|
||||
t = "0123456789abcdef"
|
||||
if flag: t = t.upper()
|
||||
n = [random.choice(t) for _ in range(e)]
|
||||
return ''.join(n)
|
||||
|
||||
def refresh_cookies(res):
|
||||
if res.cookies:
|
||||
cookies = res.cookies.get_dict()
|
||||
set_cookie = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
global activityCookie
|
||||
activityCookieMid = [i for i in activityCookie.split(';') if i != '']
|
||||
for i in activityCookieMid:
|
||||
for x in set_cookie:
|
||||
if i.split('=')[0] == x.split('=')[0]:
|
||||
if i.split('=')[1] != x.split('=')[1]:
|
||||
activityCookieMid.remove(i)
|
||||
activityCookie = ''.join(sorted([(set_cookie + ";") for set_cookie in list(set(activityCookieMid + set_cookie))]))
|
||||
|
||||
def getActivity():
|
||||
url = activityUrl
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Connection': 'keep-alive'
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
if response.status_code == 200:
|
||||
if response.cookies:
|
||||
cookies = response.cookies.get_dict()
|
||||
set_cookies = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
set_cookie = ''.join(sorted([(set_cookie + ";") for set_cookie in set_cookies]))
|
||||
return set_cookie
|
||||
else:
|
||||
print(response.status_code, "⚠️ip疑似黑了,休息一会再来撸~")
|
||||
sys.exit()
|
||||
|
||||
def getSystemConfigForNew():
|
||||
url = "https://lzdz1-isv.isvjcloud.com/wxCommonInfo/getSystemConfigForNew"
|
||||
payload = f'activityId={activityId}&activityType=99'
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getSimpleActInfoVo():
|
||||
url = "https://lzdz1-isv.isvjcloud.com/dz/common/getSimpleActInfoVo"
|
||||
payload = f"activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(f"getSimpleActInfoVo Error: {res['errorMessage']}")
|
||||
|
||||
def getMyPing(index, venderId):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/customer/getMyPing"
|
||||
payload = f"userId={venderId}&token={token}&fromType=APP"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']['nickname'], res['data']['secretPin']
|
||||
else:
|
||||
print(f"⚠️getMyPing Error: {res['errorMessage']}")
|
||||
if index == 1 and "火爆" in res['errorMessage']:
|
||||
print(f"\t⛈车头黑,退出本程序!")
|
||||
sys.exit()
|
||||
|
||||
def accessLogWithAD(venderId, pin):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/common/accessLogWithAD"
|
||||
payload = f"venderId={venderId}&code=99&pin={quote_plus(pin)}&activityId={activityId}&pageUrl={quote_plus(activityUrl)}&subType=app&adSource=null"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getSystime():
|
||||
url = "https://lzdz1-isv.isvjcloud.com/common/getSystime"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Cookie': activityCookie,
|
||||
'Content-Length': '0',
|
||||
'Connection': 'keep-alive',
|
||||
'Accept': 'application/json',
|
||||
'User-Agent': ua,
|
||||
'Referer': activityUrl,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getUserInfo(pin):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/wxActionCommon/getUserInfo"
|
||||
payload = f"pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']['nickname'], res['data']['yunMidImageUrl'], res['data']['pin']
|
||||
else:
|
||||
print(f"getUserInfo Error: {res['errorMessage']}")
|
||||
|
||||
def activityContent(pin, pinImg, nickname):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/activityContent"
|
||||
try:
|
||||
yunMidImageUrl = quote_plus(pinImg)
|
||||
except:
|
||||
yunMidImageUrl = quote_plus("https://img10.360buyimg.com/imgzone/jfs/t1/21383/2/6633/3879/5c5138d8E0967ccf2/91da57c5e2166005.jpg")
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}&pinImg={yunMidImageUrl}&nick={quote_plus(nickname)}&cjyxPin=&cjhyPin=&shareUuid={shareUuid}"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};{activityCookie}'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
if "活动已结束" in res['errorMessage']:
|
||||
sys.exit()
|
||||
|
||||
def drawContent(pin):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/dingzhi/taskact/common/drawContent"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
def checkOpenCard(shareUuid, actorUuid):
|
||||
try:
|
||||
url = "https://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/checkOpenCard"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}&shareUuid={shareUuid}&actorUuid={actorUuid}"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
# refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(f"checkOpenCard Error: {res['errorMessage']}")
|
||||
if "活动已结束" in res['errorMessage']:
|
||||
sys.exit()
|
||||
except Exception as e:
|
||||
print(f"checkOpenCard Error: {e}")
|
||||
|
||||
def getDrawRecordHasCoupon(pin, actorUuid):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/dingzhi/taskact/common/getDrawRecordHasCoupon"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}&actorUuid={actorUuid}"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
def getShareRecord(actorUuid):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/dingzhi/taskact/common/getShareRecord"
|
||||
payload = f"activityId={activityId}&actorUuid={actorUuid}"
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(f"getShareRecord Error: {res['errorMessage']}")
|
||||
|
||||
def saveTask(actorUuid, shareUuid, pin, taskType, taskValue):
|
||||
url = "https://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/saveTask"
|
||||
payload = f"activityId={activityId}&actorUuid={actorUuid}&pin={quote_plus(pin)}&shareUuid={shareUuid}&taskType={taskType}&taskValue={taskValue}&taskUuid="
|
||||
headers = {
|
||||
'Host': 'lzdz1-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzdz1-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
print(res['data'])
|
||||
return res['data']
|
||||
else:
|
||||
print(f"saveTask Error: {res['errorMessage']}")
|
||||
|
||||
def bindWithVender(cookie, venderId):
|
||||
try:
|
||||
payload = {
|
||||
'appid': 'jd_shop_member',
|
||||
'functionId': 'bindWithVender',
|
||||
'body': json.dumps({
|
||||
'venderId': venderId,
|
||||
'shopId': venderId,
|
||||
'bindByVerifyCodeFlag': 1
|
||||
}, separators=(',', ':'))
|
||||
}
|
||||
headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': ua,
|
||||
'Cookie': cookie,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': 'https://shopmember.m.jd.com/',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
response = requests.request("POST", "https://api.m.jd.com/", headers=headers, data=payload, timeout=10).text
|
||||
res = json.loads(response)
|
||||
if res['success']:
|
||||
return res['message'], res['result']['giftInfo'] if res['result'] else ""
|
||||
except Exception as e:
|
||||
print(f"bindWithVender Error: {venderId} {e}")
|
||||
|
||||
def getShopOpenCardInfo(cookie, venderId):
|
||||
try:
|
||||
body = {"venderId": str(venderId), "channel": "401"}
|
||||
url = f'https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body={json.dumps(body)}&client=H5&clientVersion=9.2.0&uuid=88888'
|
||||
headers = {
|
||||
'Host': 'api.m.jd.com',
|
||||
'Accept': '*/*',
|
||||
'Connection': 'keep-alive',
|
||||
'Cookie': cookie,
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-cn',
|
||||
'Referer': 'https://shopmember.m.jd.com/',
|
||||
'Accept-Encoding': 'gzip, deflate'
|
||||
}
|
||||
response = requests.get(url=url, headers=headers, timeout=10).text
|
||||
res = json.loads(response)
|
||||
if res['success']:
|
||||
venderCardName = res['result']['shopMemberCardInfo']['venderCardName']
|
||||
return venderCardName
|
||||
else:
|
||||
return venderId
|
||||
except:
|
||||
return venderId
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = redis_conn()
|
||||
try:
|
||||
cks = getCk
|
||||
if not cks:
|
||||
sys.exit()
|
||||
except:
|
||||
print("未获取到有效COOKIE,退出程序!")
|
||||
sys.exit()
|
||||
global shareUuid, inviteSuccNum, activityUrl, firstCk
|
||||
inviteSuccNum = 0
|
||||
if len(cks) == 1:
|
||||
shareUuid = inviterUuid
|
||||
activityUrl = activity_url
|
||||
else:
|
||||
shareUuid = remote_redis(f"lzdz1_{activityId}", 2)
|
||||
activityUrl = f"https://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/activity/5929859?activityId={activityId}&shareUuid={shareUuid}"
|
||||
num = 0
|
||||
for cookie in cks[:]:
|
||||
num += 1
|
||||
if num == 1:
|
||||
firstCk = cookie
|
||||
if num % 5 == 0:
|
||||
print("⏰等待10s,休息一下")
|
||||
time.sleep(10)
|
||||
global ua, activityCookie, token
|
||||
ua = userAgent()
|
||||
try:
|
||||
pt_pin = re.compile(r'pt_pin=(.*?);').findall(cookie)[0]
|
||||
pt_pin = unquote_plus(pt_pin)
|
||||
except IndexError:
|
||||
pt_pin = f'用户{num}'
|
||||
print(f'\n******开始【京东账号{num}】{pt_pin} *********\n')
|
||||
print(datetime.now())
|
||||
|
||||
token = getToken(cookie, r)
|
||||
if token is None:
|
||||
if num == 1:
|
||||
print(f"⚠️车头获取Token失败,退出本程序!")
|
||||
sys.exit()
|
||||
print(f"⚠️获取Token失败!⏰等待3s")
|
||||
time.sleep(3)
|
||||
continue
|
||||
time.sleep(0.3)
|
||||
activityCookie = getActivity()
|
||||
time.sleep(0.3)
|
||||
getSystemConfigForNew()
|
||||
time.sleep(0.3)
|
||||
getSimAct = getSimpleActInfoVo()
|
||||
if getSimAct:
|
||||
venderId = getSimAct['venderId']
|
||||
else:
|
||||
venderId = "1000003571"
|
||||
time.sleep(0.2)
|
||||
getPin = getMyPing(num, venderId)
|
||||
if getPin:
|
||||
nickname = getPin[0]
|
||||
secretPin = getPin[1]
|
||||
time.sleep(0.2)
|
||||
accessLogWithAD(venderId, secretPin)
|
||||
time.sleep(0.2)
|
||||
userInfo = getUserInfo(secretPin)
|
||||
if not userInfo:
|
||||
continue
|
||||
time.sleep(0.3)
|
||||
nickname = userInfo[0]
|
||||
yunMidImageUrl = userInfo[1]
|
||||
pin = userInfo[2]
|
||||
actContent = activityContent(pin, yunMidImageUrl, nickname)
|
||||
if not actContent:
|
||||
if num == 1:
|
||||
print("⚠️无法获取车头邀请码,退出本程序!")
|
||||
sys.exit()
|
||||
time.sleep(3)
|
||||
continue
|
||||
hasEnd = actContent['hasEnd']
|
||||
if hasEnd:
|
||||
print("活动已结束,下次早点来~")
|
||||
sys.exit()
|
||||
print(f"✅开启【{actContent['activityName']}】活动\n")
|
||||
|
||||
actorUuid = actContent['actorUuid']
|
||||
followShop = actContent['followShop']['allStatus']
|
||||
addSku = actContent['addSku']['allStatus']
|
||||
print(f"邀请码->: {actorUuid}")
|
||||
print(f"准备助力->: {shareUuid}")
|
||||
time.sleep(0.2)
|
||||
drawContent(pin)
|
||||
time.sleep(0.2)
|
||||
checkOC = checkOpenCard(shareUuid, actorUuid)
|
||||
allOpenCard = checkOC['allOpenCard']
|
||||
assistStatus = checkOC['assistStatus']
|
||||
beanNum = checkOC['beanNum']
|
||||
sendBeanNum = checkOC['sendBeanNum']
|
||||
cardList = checkOC['cardList']
|
||||
assStat = False
|
||||
if allOpenCard:
|
||||
print("已完成全部开卡任务")
|
||||
if assistStatus == 0:
|
||||
print("已经助力过你~")
|
||||
elif assistStatus == 2:
|
||||
print("已经助力过你~")
|
||||
elif assistStatus == 3:
|
||||
print("已助力过其他好友~")
|
||||
elif assistStatus == 1:
|
||||
print("已完成开卡关注任务,未助力过好友~")
|
||||
assStat = True
|
||||
else:
|
||||
assStat = True
|
||||
else:
|
||||
openCardLists = [(int(i['value']), i['name']) for i in cardList if i['status'] == 0]
|
||||
print(f"现在去开卡,共计{len(openCardLists)}个会员💳")
|
||||
open_num = 0
|
||||
for shop in openCardLists:
|
||||
open_num += 1
|
||||
print(f"去开卡 {open_num}/{len(openCardLists)} {shop[0]}")
|
||||
venderId = shop[0]
|
||||
venderCardName = shop[1]
|
||||
getShopOpenCardInfo(cookie, venderId)
|
||||
open_result = bindWithVender(cookie, venderId)
|
||||
if open_result is not None:
|
||||
if "火爆" in open_result[0] or "失败" in open_result[0] or "解绑" in open_result[0]:
|
||||
time.sleep(1.5)
|
||||
print(f"\t⛈⛈{venderCardName} {open_result[0]}")
|
||||
assStat = False
|
||||
break
|
||||
else:
|
||||
print(f"\t🎉🎉{venderCardName} {open_result[0]}")
|
||||
assStat = True
|
||||
if open_result[1]:
|
||||
print(f"\t🎁获得{','.join([gift['discountString'] + gift['prizeName'] for gift in open_result[1]['giftList']])}")
|
||||
if open_num % 5 == 0:
|
||||
print("⏰等待5s,休息一下")
|
||||
time.sleep(5)
|
||||
else:
|
||||
time.sleep(2)
|
||||
checkOC = checkOpenCard(shareUuid, actorUuid)
|
||||
if not checkOC:
|
||||
time.sleep(5)
|
||||
continue
|
||||
sendBeanNum = checkOC['sendBeanNum']
|
||||
allOpenCard = checkOC['allOpenCard']
|
||||
assistStatus = checkOC['assistStatus']
|
||||
if sendBeanNum > 0:
|
||||
print(f"\t🎁开卡获得{sendBeanNum}豆")
|
||||
else:
|
||||
print(f"\t🤖开卡可能没水啦!")
|
||||
if allOpenCard and assistStatus == 1:
|
||||
assStat = True
|
||||
activityContent(pin, yunMidImageUrl, nickname)
|
||||
time.sleep(0.5)
|
||||
drawContent(pin)
|
||||
print("现在去一键关注店铺")
|
||||
saveTask(actorUuid, shareUuid, pin, 1, 1)
|
||||
time.sleep(0.3)
|
||||
print("现在去一键加购")
|
||||
saveTask(actorUuid, shareUuid, pin, 2, 2)
|
||||
time.sleep(0.3)
|
||||
getSR = getShareRecord(actorUuid)
|
||||
if getSR and num == 1:
|
||||
print(f"🧑🤝🧑已经邀请{len(getSR)}人")
|
||||
if assStat and num != 1:
|
||||
print("🎉🎉🎉助力成功~")
|
||||
inviteSuccNum += 1
|
||||
print(f"本次车头已邀请{inviteSuccNum}人")
|
||||
if num == 1:
|
||||
print(f"后面账号全部助力 {actorUuid}")
|
||||
shareUuid = actorUuid
|
||||
activityUrl = f"https://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/activity/5929859?activityId={activityId}&shareUuid={shareUuid}"
|
||||
|
||||
time.sleep(3)
|
579
jd_wdz.py
579
jd_wdz.py
@ -1,579 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
File: jd_wdz.py(微定制组队瓜分-监控脚本)
|
||||
Author: HarbourJ
|
||||
Date: 2022/8/12 20:37
|
||||
TG: https://t.me/HarbourToulu
|
||||
TgChat: https://t.me/HarbourSailing
|
||||
cron: 1 1 1 1 1 1
|
||||
new Env('微定制组队瓜分-JK');
|
||||
ActivityEntry: https://cjhydz-isv.isvjcloud.com/microDz/invite/activity/wx/view/index?activityId=eb24d792fdcf4732be29030f9fc8e007
|
||||
Description: 微定制组队通用脚本
|
||||
本地sign算法+redis缓存Token+代理ip(自行配置,实测可行)
|
||||
变量: export jd_wdz_activityId="eb24d792fdcf4732be29030f9fc8e007"
|
||||
Update: 2022/11/01 更新入会算法,内置船新入会本地算法
|
||||
"""
|
||||
|
||||
import time, requests, sys, re, os, json, random
|
||||
from datetime import datetime
|
||||
from urllib.parse import quote_plus, unquote_plus
|
||||
from functools import partial
|
||||
print = partial(print, flush=True)
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
try:
|
||||
from jd_sign import *
|
||||
except ImportError as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
print("请先运行Faker库依赖一键安装脚本(jd_check_dependent.py),安装jd_sign.so依赖")
|
||||
try:
|
||||
from jdCookie import get_cookies
|
||||
getCk = get_cookies()
|
||||
except:
|
||||
print("请先下载依赖脚本,\n下载链接: https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
|
||||
sys.exit(3)
|
||||
|
||||
redis_url = os.environ.get("redis_url") if os.environ.get("redis_url") else "172.17.0.1"
|
||||
redis_port = os.environ.get("redis_port") if os.environ.get("redis_port") else "6379"
|
||||
redis_pwd = os.environ.get("redis_pwd") if os.environ.get("redis_pwd") else ""
|
||||
jd_wdz_activityId = os.environ.get("jd_wdz_activityId") if os.environ.get("jd_wdz_activityId") else ""
|
||||
|
||||
if not jd_wdz_activityId:
|
||||
print("⚠️未发现有效活动变量,退出程序!")
|
||||
sys.exit()
|
||||
# 获取远程remote-redis活动ID
|
||||
if "wdz_remote" in jd_wdz_activityId:
|
||||
jd_wdzId_remote = remote_redis(jd_wdz_activityId)
|
||||
jd_wdz_activityId = jd_wdzId_remote
|
||||
activityId = jd_wdz_activityId
|
||||
activity_url = f"https://cjhy-isv.isvjcloud.com/microDz/invite/activity/wx/view/index/3499100?activityId={activityId}"
|
||||
print(f"【🛳活动入口】{activity_url}")
|
||||
|
||||
def redis_conn():
|
||||
try:
|
||||
import redis
|
||||
try:
|
||||
pool = redis.ConnectionPool(host=redis_url, port=redis_port, decode_responses=True, socket_connect_timeout=5, password=redis_pwd)
|
||||
r = redis.Redis(connection_pool=pool)
|
||||
r.get('conn_test')
|
||||
print('✅redis连接成功')
|
||||
return r
|
||||
except:
|
||||
print("⚠️redis连接异常")
|
||||
except:
|
||||
print("⚠️缺少redis依赖,请运行pip3 install redis")
|
||||
sys.exit()
|
||||
|
||||
def getToken(ck, r=None):
|
||||
host = f'{activityUrl.split("com/")[0]}com'
|
||||
try:
|
||||
# redis缓存Token 活动域名+pt_pin
|
||||
pt_pin = unquote_plus(re.compile(r'pt_pin=(.*?);').findall(ck)[0])
|
||||
except:
|
||||
# redis缓存Token 活动域名+ck前7位(获取pin失败)
|
||||
pt_pin = ck[:15]
|
||||
try:
|
||||
if r is not None:
|
||||
Token = r.get(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}')
|
||||
# print("Token过期时间", r.ttl(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}'))
|
||||
if Token is not None:
|
||||
print(f"♻️获取缓存Token")
|
||||
return Token
|
||||
else:
|
||||
# print("🈳去设置Token缓存")
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign_txt = sign({"url": f"{host}", "id": ""}, 'isvObfuscator')
|
||||
# print(sign_txt)
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
return
|
||||
Token_new = f.json()['token']
|
||||
# print(f"Token->: {Token_new}")
|
||||
if r.set(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}', Token_new, ex=1800):
|
||||
print("✅Token缓存成功")
|
||||
else:
|
||||
print("❌Token缓存失败")
|
||||
return Token_new
|
||||
else:
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign_txt = sign({"url": f"{host}", "id": ""}, 'isvObfuscator')
|
||||
# print(sign_txt)
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
return
|
||||
Token = f.json()['token']
|
||||
print(f"✅获取实时Token")
|
||||
return Token
|
||||
except:
|
||||
return
|
||||
|
||||
def getJdTime():
|
||||
jdTime = int(round(time.time() * 1000))
|
||||
return jdTime
|
||||
|
||||
def randomString(e, flag=False):
|
||||
t = "0123456789abcdef"
|
||||
if flag: t = t.upper()
|
||||
n = [random.choice(t) for _ in range(e)]
|
||||
return ''.join(n)
|
||||
|
||||
def refresh_cookies(res):
|
||||
if res.cookies:
|
||||
cookies = res.cookies.get_dict()
|
||||
set_cookie = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
global activityCookie
|
||||
activityCookieMid = [i for i in activityCookie.split(';') if i != '']
|
||||
for i in activityCookieMid:
|
||||
for x in set_cookie:
|
||||
if i.split('=')[0] == x.split('=')[0]:
|
||||
if i.split('=')[1] != x.split('=')[1]:
|
||||
activityCookieMid.remove(i)
|
||||
activityCookie = ''.join(sorted([(set_cookie + ";") for set_cookie in list(set(activityCookieMid + set_cookie))]))
|
||||
|
||||
def getActivity():
|
||||
url = activityUrl
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Connection': 'keep-alive'
|
||||
}
|
||||
try:
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
if "活动未开始" in response.text:
|
||||
print("⚠活动未开始,晚点再来~")
|
||||
sys.exit()
|
||||
if response.status_code == 493:
|
||||
print(response.status_code, "⚠️ip疑似黑了,休息一会再来撸~")
|
||||
sys.exit()
|
||||
if response.cookies:
|
||||
cookies = response.cookies.get_dict()
|
||||
set_cookies = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
set_cookie = ''.join(sorted([(set_cookie + ";") for set_cookie in set_cookies]))
|
||||
return set_cookie
|
||||
except:
|
||||
print("⚠️ip疑似黑了,休息一会再来撸~")
|
||||
sys.exit()
|
||||
|
||||
def getSystemConfigForNew():
|
||||
url = "https://cjhy-isv.isvjcloud.com/wxCommonInfo/getSystemConfigForNew"
|
||||
payload = f'activityId={activityId}&activityType=99'
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getMyPing(index):
|
||||
url = "https://cjhy-isv.isvjcloud.com/customer/getMyPing"
|
||||
payload = f"userId=599119&token={token}&fromType=APP&riskType=1"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.status_code)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']['nickname'], res['data']['secretPin'], res['data']['yunMidImageUrl']
|
||||
else:
|
||||
print(f"⚠️{res['errorMessage']}")
|
||||
if index == 1 and "火爆" in res['errorMessage']:
|
||||
print(f"\t⛈车头黑,退出本程序!")
|
||||
sys.exit()
|
||||
|
||||
def getSimpleActInfoVo():
|
||||
url = "https://cjhy-isv.isvjcloud.com/microDz/invite/activity/wx/getActivityInfo"
|
||||
payload = f"activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
# refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']['beansResidueByDay'], res['data']['residualPercentage'], res['data']['maxGroup'], res['data']['venderIds'], res['data']['actRule']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def accessLog(pin):
|
||||
url = "https://cjhy-isv.isvjcloud.com/common/accessLog"
|
||||
payload = f"venderId=1&code=99&pin={quote_plus(quote_plus(pin))}&activityId={activityId}&pageUrl={quote_plus(activityUrl)}&subType=app"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getUserInfo(pin):
|
||||
url = "https://cjhy-isv.isvjcloud.com/wxActionCommon/getUserInfo"
|
||||
payload = f"pin={quote_plus(quote_plus(pin))}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']['nickname'], res['data']['yunMidImageUrl'], res['data']['pin']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def getOpenCardAllStatuesNew(pin, again=1):
|
||||
url = "https://cjhy-isv.isvjcloud.com/microDz/invite/activity/wx/getOpenCardAllStatuesNew"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(quote_plus(pin))}&isInvited=1"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
# refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
if not res['data']['list']:
|
||||
print(f"第{again}次重试")
|
||||
if again <= 3:
|
||||
time.sleep(2)
|
||||
again += 1
|
||||
return getOpenCardAllStatuesNew(pin, again=again)
|
||||
return res['data']['isCanJoin'], res['data']['reward'], res['data']['list']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def isInvited(pin):
|
||||
url = "https://cjhy-isv.isvjcloud.com/microDz/invite/activity/wx/isInvited"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(quote_plus(pin))}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
# refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def acceptInvite(inviterNick, inviterPin, inviterImg, pin, nickName, inviteeImg):
|
||||
url = "https://cjhy-isv.isvjcloud.com/microDz/invite/activity/wx/acceptInvite"
|
||||
try:
|
||||
inviteeImg = quote_plus(inviteeImg)
|
||||
except:
|
||||
inviteeImg = quote_plus("https://img10.360buyimg.com/imgzone/jfs/t1/21383/2/6633/3879/5c5138d8E0967ccf2/91da57c5e2166005.jpg")
|
||||
payload = f"activityId={activityId}&inviter={quote_plus(quote_plus(inviterPin))}&inviterImg={inviterImg}&inviterNick={quote_plus(inviterNick)}&invitee={quote_plus(quote_plus(pin))}&inviteeImg={inviteeImg}&inviteeNick={quote_plus(nickName)}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
# refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def bindWithVender(cookie, venderId):
|
||||
try:
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': ua,
|
||||
'Cookie': cookie,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': f'https://shopmember.m.jd.com/shopcard/?venderId={venderId}&returnUrl={quote_plus(activityUrl)}',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
s.params = {
|
||||
'appid': 'jd_shop_member',
|
||||
'functionId': 'bindWithVender',
|
||||
'body': json.dumps({
|
||||
'venderId': venderId,
|
||||
'shopId': venderId,
|
||||
'bindByVerifyCodeFlag': 1
|
||||
}, separators=(',', ':'))
|
||||
}
|
||||
res = s.post('https://api.m.jd.com/', verify=False, timeout=30).json()
|
||||
if res['success']:
|
||||
return res['message']
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def getShopOpenCardInfo(cookie, venderId):
|
||||
shopcard_url = f"https://shopmember.m.jd.com/shopcard/?venderId={venderId}&channel=401&returnUrl={quote_plus(activityUrl)}"
|
||||
try:
|
||||
body = {"venderId": str(venderId), "channel": "401"}
|
||||
url = f'https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body={json.dumps(body)}&client=H5&clientVersion=9.2.0&uuid=88888'
|
||||
headers = {
|
||||
'Host': 'api.m.jd.com',
|
||||
'Accept': '*/*',
|
||||
'Connection': 'keep-alive',
|
||||
'Cookie': cookie,
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-cn',
|
||||
'Referer': shopcard_url,
|
||||
'Accept-Encoding': 'gzip, deflate'
|
||||
}
|
||||
response = requests.get(url=url, headers=headers, timeout=5).text
|
||||
res = json.loads(response)
|
||||
if res['success']:
|
||||
venderCardName = res['result']['shopMemberCardInfo']['venderCardName']
|
||||
return venderCardName
|
||||
else:
|
||||
return venderId
|
||||
except:
|
||||
return venderId
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = redis_conn()
|
||||
try:
|
||||
cks = getCk
|
||||
if not cks:
|
||||
sys.exit()
|
||||
except:
|
||||
print("未获取到有效COOKIE,退出程序!")
|
||||
sys.exit()
|
||||
global inviterNick, inviterPin, inviterImg, inviteSuccNum, activityUrl, firstCk
|
||||
inviteSuccNum = 0
|
||||
try:
|
||||
UUID = remote_redis(f"wdz_{activityId}", 3)
|
||||
inviterPin = UUID.split('&')[0]
|
||||
inviterNick = UUID.split('&')[1]
|
||||
except:
|
||||
inviterPin = ""
|
||||
inviterNick = ""
|
||||
inviterImg = "https://img10.360buyimg.com/imgzone/jfs/t1/21383/2/6633/3879/5c5138d8E0967ccf2/91da57c5e2166005.jpg"
|
||||
activityUrl = f"https://cjhy-isv.isvjcloud.com/microDz/invite/activity/wx/view/index/3499100?activityId={activityId}&inviter={inviterPin}&inviterImg=https://img10.360buyimg.com/imgzone/jfs/t1/21383/2/6633/3879/5c5138d8E0967ccf2/91da57c5e2166005.jpg&inviterNickName={quote_plus(inviterNick)}"
|
||||
|
||||
num = 0
|
||||
for cookie in cks[:]:
|
||||
num += 1
|
||||
if num == 1:
|
||||
firstCk = cookie
|
||||
if num % 9 == 0:
|
||||
print("⏰等待10s,休息一下")
|
||||
time.sleep(10)
|
||||
global ua, activityCookie, token
|
||||
ua = userAgent()
|
||||
try:
|
||||
pt_pin = re.compile(r'pt_pin=(.*?);').findall(cookie)[0]
|
||||
pt_pin = unquote_plus(pt_pin)
|
||||
except IndexError:
|
||||
pt_pin = f'用户{num}'
|
||||
print(f'\n******开始【京东账号{num}】{pt_pin} *********\n')
|
||||
print(datetime.now())
|
||||
|
||||
token = getToken(cookie, r)
|
||||
if token is None:
|
||||
if num == 1:
|
||||
print(f"⚠️车头获取Token失败,退出本程序!")
|
||||
sys.exit()
|
||||
print(f"⚠️获取Token失败!⏰等待3s")
|
||||
time.sleep(3)
|
||||
continue
|
||||
time.sleep(0.5)
|
||||
activityCookie = getActivity()
|
||||
time.sleep(0.5)
|
||||
getSimAct = getSimpleActInfoVo()
|
||||
beansResidueByDay = getSimAct[0]
|
||||
residualPercentage = getSimAct[1]
|
||||
maxGroup = getSimAct[2]
|
||||
venderIds = getSimAct[3]
|
||||
actRule = getSimAct[4]
|
||||
actRule0 = actRule.replace("\n", "").split("</br>4")[0].split("</br>3)")[1]
|
||||
try:
|
||||
maxGroups = int(actRule0.split("最多可组队")[1].split("次")[0])
|
||||
except:
|
||||
maxGroups = 5
|
||||
if num == 1:
|
||||
print(f"【活动规则】{actRule0}")
|
||||
print(f"【剩余京豆】{beansResidueByDay}")
|
||||
print(f"【豆池进度】{residualPercentage}%")
|
||||
if int(beansResidueByDay) == 0 or residualPercentage == 0:
|
||||
print("豆池已空💨💨💨,下次早点来~")
|
||||
sys.exit()
|
||||
time.sleep(0.2)
|
||||
getPin = getMyPing(num)
|
||||
if getPin:
|
||||
nickName = getPin[0]
|
||||
secretPin = getPin[1]
|
||||
yunMidImageUrl = getPin[2]
|
||||
time.sleep(0.5)
|
||||
accessLog(secretPin)
|
||||
time.sleep(0.5)
|
||||
getOpenAllStat = getOpenCardAllStatuesNew(secretPin)
|
||||
if getOpenAllStat:
|
||||
isCanJoin = getOpenAllStat[0]
|
||||
reward = getOpenAllStat[1]
|
||||
shopList = getOpenAllStat[2]
|
||||
venderIds = venderIds.split(',')
|
||||
unOpenCardLists = [(venderIds[i], val['shopName']) for i, val in enumerate(shopList) if not val['statue']]
|
||||
errorShopCard = 0
|
||||
if unOpenCardLists:
|
||||
print(f"未开卡店铺 {len(unOpenCardLists)}个")
|
||||
for shop in unOpenCardLists:
|
||||
print(f"去开卡 {shop[0]}")
|
||||
venderId = shop[0]
|
||||
venderCardName = shop[1]
|
||||
getShopOpenCardInfo(cookie, venderId)
|
||||
open_result = bindWithVender(cookie, venderId)
|
||||
if open_result is not None:
|
||||
if "火爆" in open_result or "失败" in open_result:
|
||||
time.sleep(1.2)
|
||||
print("\t尝试重新入会 第1次")
|
||||
open_result = bindWithVender(cookie, venderId)
|
||||
if "火爆" in open_result or "失败" in open_result:
|
||||
time.sleep(1.2)
|
||||
print("\t尝试重新入会 第2次")
|
||||
open_result = bindWithVender(cookie, venderId)
|
||||
if "火爆" in open_result or "失败" in open_result:
|
||||
print(f"\t⛈⛈{venderCardName} {open_result}")
|
||||
errorShopCard += 1
|
||||
else:
|
||||
print(f"\t🎉🎉{venderCardName} {open_result}")
|
||||
if "已经" in open_result or "绑定" in open_result:
|
||||
errorShopCard += 1
|
||||
time.sleep(1.5)
|
||||
isInvi = isInvited(secretPin)
|
||||
if isInvi['isInvited']:
|
||||
print(f"已加入队伍信息: {isInvi['nickName']}, {isInvi['inviter']}")
|
||||
if not isInvi['isInvited'] and isCanJoin:
|
||||
acceptInvite(inviterNick, inviterPin, inviterImg, secretPin, nickName, yunMidImageUrl)
|
||||
getSimpleActInfoVo()
|
||||
getOpenCardAllStatuesNew(secretPin)
|
||||
isInvi = isInvited(secretPin)
|
||||
if isInvi['isInvited']:
|
||||
if errorShopCard > 0:
|
||||
print("⛈加入队伍成功,被邀请者账号未全部开卡")
|
||||
else:
|
||||
print(f"🎉加入{isInvi['nickName']}队伍成功")
|
||||
inviteSuccNum += 1
|
||||
print(f"本次车头已邀请{inviteSuccNum}人")
|
||||
if inviteSuccNum >= maxGroup * maxGroups:
|
||||
print(f"已达到{maxGroups}组好友,退出程序~")
|
||||
sys.exit()
|
||||
else:
|
||||
print("😐加入队伍失败")
|
||||
if num == 1:
|
||||
inviterPin = secretPin
|
||||
inviterImg = yunMidImageUrl
|
||||
if not inviterImg:
|
||||
inviterImg = "https://img10.360buyimg.com/imgzone/jfs/t1/21383/2/6633/3879/5c5138d8E0967ccf2/91da57c5e2166005.jpg"
|
||||
inviterNick = nickName
|
||||
activityUrl = f"https://cjhy-isv.isvjcloud.com/microDz/invite/activity/wx/view/index/3499100?activityId={activityId}&inviter={quote_plus(quote_plus(inviterPin))}&inviterImg={quote_plus(inviterImg)}&inviterNickName={quote_plus(inviterNick)}"
|
||||
|
||||
time.sleep(3)
|
@ -1,559 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
File: jd_wxBirthGifts.py(生日等级礼包-监控脚本)
|
||||
Author: HarbourJ
|
||||
Date: 2022/8/8 19:52
|
||||
TG: https://t.me/HarbourToulu
|
||||
TgChat: https://t.me/HarbourChat
|
||||
cron: 1 1 1 1 1 1
|
||||
new Env('生日等级礼包-JK');
|
||||
ActivityEntry: https://cjhy-isv.isvjcloud.com/mc/wxMcLevelAndBirthGifts/activity?activityId=f3325e3375a14866xxxxxxxxxxxx
|
||||
变量 export jd_wxBirthGiftsId="活动🆔"
|
||||
Update: 20221205 新增等级礼包模块
|
||||
"""
|
||||
|
||||
import time, requests, sys, re, os, json, random
|
||||
from datetime import datetime
|
||||
from urllib.parse import quote_plus, unquote_plus
|
||||
from functools import partial
|
||||
print = partial(print, flush=True)
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
try:
|
||||
from jd_sign import *
|
||||
except ImportError as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
print("请先运行Faker库依赖一键安装脚本(jd_check_dependent.py),安装jd_sign.so依赖")
|
||||
sys.exit()
|
||||
try:
|
||||
from jdCookie import get_cookies
|
||||
getCk = get_cookies()
|
||||
except:
|
||||
print("请先下载依赖脚本,\n下载链接: https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
|
||||
sys.exit(3)
|
||||
redis_url = os.environ.get("redis_url") if os.environ.get("redis_url") else "172.17.0.1"
|
||||
redis_port = os.environ.get("redis_port") if os.environ.get("redis_port") else "6379"
|
||||
redis_pwd = os.environ.get("redis_pwd") if os.environ.get("redis_pwd") else ""
|
||||
activityId = os.environ.get("jd_wxBirthGiftsId") if os.environ.get("jd_wxBirthGiftsId") else ""
|
||||
|
||||
if not activityId:
|
||||
print("⚠️未发现有效活动变量,退出程序!")
|
||||
sys.exit()
|
||||
activityUrl = f"https://cjhy-isv.isvjcloud.com/mc/wxMcLevelAndBirthGifts/activity?activityId={activityId}"
|
||||
print(f"【🛳活动入口】{activityUrl}")
|
||||
|
||||
def redis_conn():
|
||||
try:
|
||||
try:
|
||||
import redis
|
||||
except Exception as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
os.system("pip install redis")
|
||||
import redis
|
||||
try:
|
||||
pool = redis.ConnectionPool(host=redis_url, port=redis_port, decode_responses=True, socket_connect_timeout=5, password=redis_pwd)
|
||||
r = redis.Redis(connection_pool=pool)
|
||||
r.get('conn_test')
|
||||
print('✅redis连接成功')
|
||||
return r
|
||||
except:
|
||||
print("⚠️redis连接异常")
|
||||
except:
|
||||
print("⚠️缺少redis依赖,请运行pip3 install redis")
|
||||
sys.exit()
|
||||
|
||||
def getToken(ck, r=None):
|
||||
host = f'{activityUrl.split("com/")[0]}com'
|
||||
try:
|
||||
# redis缓存Token 活动域名+pt_pin
|
||||
pt_pin = unquote_plus(re.compile(r'pt_pin=(.*?);').findall(ck)[0])
|
||||
except:
|
||||
# redis缓存Token 活动域名+ck前7位(获取pin失败)
|
||||
pt_pin = ck[:15]
|
||||
try:
|
||||
if r is not None:
|
||||
Token = r.get(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}')
|
||||
# print("Token过期时间", r.ttl(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}'))
|
||||
if Token is not None:
|
||||
print(f"♻️获取缓存Token")
|
||||
return Token
|
||||
else:
|
||||
# print("🈳去设置Token缓存")
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign_txt = sign({"url": f"{host}", "id": ""}, 'isvObfuscator')
|
||||
# print(sign_txt)
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
return
|
||||
Token_new = f.json()['token']
|
||||
# print(f"Token->: {Token_new}")
|
||||
if r.set(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}', Token_new, ex=1800):
|
||||
print("✅Token缓存成功")
|
||||
else:
|
||||
print("❌Token缓存失败")
|
||||
return Token_new
|
||||
else:
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign_txt = sign({"url": f"{host}", "id": ""}, 'isvObfuscator')
|
||||
# print(sign_txt)
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
return
|
||||
Token = f.json()['token']
|
||||
print(f"✅获取实时Token")
|
||||
return Token
|
||||
except:
|
||||
return
|
||||
|
||||
def getJdTime():
|
||||
jdTime = int(round(time.time() * 1000))
|
||||
return jdTime
|
||||
|
||||
def randomString(e, flag=False):
|
||||
t = "0123456789abcdef"
|
||||
if flag: t = t.upper()
|
||||
n = [random.choice(t) for _ in range(e)]
|
||||
return ''.join(n)
|
||||
|
||||
def refresh_cookies(res):
|
||||
if res.cookies:
|
||||
cookies = res.cookies.get_dict()
|
||||
set_cookie = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
global activityCookie
|
||||
activityCookieMid = [i for i in activityCookie.split(';') if i != '']
|
||||
for i in activityCookieMid:
|
||||
for x in set_cookie:
|
||||
if i.split('=')[0] == x.split('=')[0]:
|
||||
if i.split('=')[1] != x.split('=')[1]:
|
||||
activityCookieMid.remove(i)
|
||||
activityCookie = ''.join(sorted([(set_cookie + ";") for set_cookie in list(set(activityCookieMid + set_cookie))]))
|
||||
|
||||
def getActivity():
|
||||
url = activityUrl
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Connection': 'keep-alive'
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
if response.status_code == 200:
|
||||
if response.cookies:
|
||||
cookies = response.cookies.get_dict()
|
||||
set_cookies = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
set_cookie = ''.join(sorted([(set_cookie + ";") for set_cookie in set_cookies]))
|
||||
return set_cookie
|
||||
else:
|
||||
print(response.status_code)
|
||||
print("⚠️疑似ip黑了")
|
||||
sys.exit()
|
||||
|
||||
def getOpenStatus():
|
||||
url = "https://cjhy-isv.isvjcloud.com/assembleConfig/getOpenStatus"
|
||||
payload = f'activityId={activityId}'
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
def getSystemConfig():
|
||||
url = "https://cjhy-isv.isvjcloud.com/wxCommonInfo/getSystemConfig"
|
||||
payload = f'activityId={activityId}&activityType='
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getSimpleActInfoVo():
|
||||
url = "https://cjhy-isv.isvjcloud.com/customer/getSimpleActInfoVo"
|
||||
payload = f"activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def getMyPing(venderId):
|
||||
url = "https://cjhy-isv.isvjcloud.com/customer/getMyPing"
|
||||
payload = f"userId={venderId}&token={token}&fromType=APP&riskType=1"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']['nickname'], res['data']['secretPin']
|
||||
else:
|
||||
print(f"⚠️{res['errorMessage']}")
|
||||
|
||||
def getMemberLevel(venderId, pin):
|
||||
url = "https://cjhy-isv.isvjcloud.com/mc/wxMcLevelAndBirthGifts/getMemberLevel"
|
||||
payload = f"venderId={venderId}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def getOpenCardInfo(venderId, pin, activityType):
|
||||
url = "https://cjhy-isv.isvjcloud.com/mc/new/brandCard/common/shopAndBrand/getOpenCardInfo"
|
||||
payload = f"venderId={venderId}&buyerPin={quote_plus(pin)}&activityType={activityType}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def accessLog(venderId, pin, activityType):
|
||||
url = "https://cjhy-isv.isvjcloud.com/common/accessLog"
|
||||
payload = f"venderId={venderId}&code={activityType}&pin={quote_plus(pin)}&activityId={activityId}&pageUrl={quote_plus(activityUrl)}&subType="
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
def activityContent(pin, level):
|
||||
url = "https://cjhy-isv.isvjcloud.com/mc/wxMcLevelAndBirthGifts/activityContent"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}&level={level}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};{activityCookie}'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
endTime = res['data']['endTime']
|
||||
if getJdTime() > endTime:
|
||||
print("⛈活动已结束,下次早点来~")
|
||||
sys.exit()
|
||||
return res['data']
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
|
||||
def getInfo():
|
||||
url = f"https://cjhy-isv.isvjcloud.com/miniProgramShareInfo/getInfo?activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getBirthInfo(venderId, pin):
|
||||
url = "https://cjhy-isv.isvjcloud.com/mc/wxMcLevelAndBirthGifts/getBirthInfo"
|
||||
payload = f"venderId={venderId}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};{activityCookie}'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def saveBirthDay(venderId, pin):
|
||||
url = "https://cjhy-isv.isvjcloud.com/mc/wxMcLevelAndBirthGifts/saveBirthDay"
|
||||
payload = f"venderId={venderId}&pin={quote_plus(pin)}&birthDay={str(datetime.now())[:10]}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};{activityCookie}'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def sendBirthGifts(venderId, pin, level):
|
||||
url = "https://cjhy-isv.isvjcloud.com/mc/wxMcLevelAndBirthGifts/sendBirthGifts"
|
||||
payload = f"venderId={venderId}&pin={quote_plus(pin)}&activityId={activityId}&level={level}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};{activityCookie}'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
|
||||
def sendLevelGifts(venderId, pin, level):
|
||||
url = "https://cjhy-isv.isvjcloud.com/mc/wxMcLevelAndBirthGifts/sendLevelGifts"
|
||||
payload = f"venderId={venderId}&pin={quote_plus(pin)}&activityId={activityId}&level={level}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};{activityCookie}'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = redis_conn()
|
||||
try:
|
||||
cks = getCk
|
||||
if not cks:
|
||||
sys.exit()
|
||||
except:
|
||||
print("未获取到有效COOKIE,退出程序!")
|
||||
sys.exit()
|
||||
num = 0
|
||||
for cookie in cks[:]:
|
||||
num += 1
|
||||
if num % 9 == 0:
|
||||
print("⏰等待5s,休息一下")
|
||||
time.sleep(5)
|
||||
global ua, activityCookie, token
|
||||
ua = userAgent()
|
||||
try:
|
||||
pt_pin = re.compile(r'pt_pin=(.*?);').findall(cookie)[0]
|
||||
pt_pin = unquote_plus(pt_pin)
|
||||
except IndexError:
|
||||
pt_pin = f'用户{num}'
|
||||
print(f'\n******开始【京东账号{num}】{pt_pin} *********\n')
|
||||
print(datetime.now())
|
||||
token = getToken(cookie, r)
|
||||
if token is None:
|
||||
print(f"⚠️获取Token失败!⏰等待2s")
|
||||
time.sleep(2)
|
||||
continue
|
||||
time.sleep(0.2)
|
||||
activityCookie = getActivity()
|
||||
time.sleep(0.3)
|
||||
getOpenStatus()
|
||||
time.sleep(0.2)
|
||||
getSimAct = getSimpleActInfoVo()
|
||||
venderId = getSimAct['venderId']
|
||||
activityType = getSimAct['activityType']
|
||||
time.sleep(0.3)
|
||||
getPin = getMyPing(venderId)
|
||||
if getPin:
|
||||
nickname = getPin[0]
|
||||
secretPin = getPin[1]
|
||||
time.sleep(0.3)
|
||||
getOC = getOpenCardInfo(venderId, secretPin, activityType)
|
||||
time.sleep(0.2)
|
||||
if getOC['openedCard']:
|
||||
memberLev = getMemberLevel(venderId, secretPin)
|
||||
if memberLev:
|
||||
level = memberLev['level']
|
||||
shopTitle = memberLev['shopTitle']
|
||||
print(f"✅开启{shopTitle} 生日等级礼包")
|
||||
time.sleep(0.2)
|
||||
accessLog(venderId, secretPin, activityType)
|
||||
time.sleep(0.2)
|
||||
actContent = activityContent(secretPin, level)
|
||||
if actContent:
|
||||
if actContent['isReceived'] == 1:
|
||||
print(f"💨{nickname} 今年已经领过了,明年再来吧~")
|
||||
continue
|
||||
else:
|
||||
time.sleep(0.2)
|
||||
getInfo()
|
||||
time.sleep(0.2)
|
||||
try:
|
||||
if activityType == 104:
|
||||
sendGift = sendLevelGifts(venderId, secretPin, level)
|
||||
levelResult = sendGift['levelResult']
|
||||
if levelResult:
|
||||
levelData = sendGift['levelData']
|
||||
gifts = [(f"{x['beanNum']}{x['name']}") for x in levelData]
|
||||
print(f"🎉🎉🎉{nickname} 成功领取 {','.join(gifts)}")
|
||||
else:
|
||||
print(f"💨{nickname} 生日等级礼包领取失败,请重试~")
|
||||
else:
|
||||
getBirthInfo(venderId, secretPin)
|
||||
time.sleep(0.2)
|
||||
saveBirthDay(venderId, secretPin)
|
||||
time.sleep(0.2)
|
||||
sendGift = sendBirthGifts(venderId, secretPin, level)
|
||||
birthdayResult = sendGift['birthdayResult']
|
||||
if birthdayResult:
|
||||
birthdayData = sendGift['birthdayData']
|
||||
gifts = [(f"{x['beanNum']}{x['name']}") for x in birthdayData]
|
||||
print(f"🎉🎉🎉{nickname} 成功领取 {','.join(gifts)}")
|
||||
else:
|
||||
print(f"💨{nickname} 生日等级礼包领取失败,请重试~")
|
||||
except:
|
||||
print(f"💨{nickname} 生日等级礼包领取失败,请重试~")
|
||||
else:
|
||||
print(f"⛈{nickname} 非店铺会员无法领取生日等级礼包!")
|
||||
continue
|
||||
time.sleep(1.5)
|
@ -1,521 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
File: jd_wxBulidActivity.py(盖楼有礼-监控脚本)
|
||||
Author: HarbourJ
|
||||
Date: 2022/9/18 19:52
|
||||
TG: https://t.me/HarbourToulu
|
||||
TgChat: https://t.me/HarbourSailing
|
||||
cron: 1 1 1 1 1 1
|
||||
new Env('盖楼有礼-JK');
|
||||
ActivityEntry: https://lzkj-isv.isvjcloud.com/wxBuildActivity/activity?activityId=4bde809b95ec45a3b50f7086d77f3178
|
||||
"""
|
||||
|
||||
import time, requests, sys, re, os, json, random
|
||||
from datetime import datetime
|
||||
from urllib.parse import quote_plus, unquote_plus
|
||||
from functools import partial
|
||||
print = partial(print, flush=True)
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
try:
|
||||
from jd_sign import *
|
||||
except ImportError as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
print("请先运行Faker库依赖一键安装脚本(jd_check_dependent.py),安装jd_sign.so依赖")
|
||||
try:
|
||||
from jdCookie import get_cookies
|
||||
getCk = get_cookies()
|
||||
except:
|
||||
print("请先下载依赖脚本,\n下载链接: https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
|
||||
sys.exit(3)
|
||||
redis_url = os.environ.get("redis_url") if os.environ.get("redis_url") else "172.17.0.1"
|
||||
redis_port = os.environ.get("redis_port") if os.environ.get("redis_port") else "6379"
|
||||
redis_pwd = os.environ.get("redis_pwd") if os.environ.get("redis_pwd") else ""
|
||||
activityId = os.environ.get("jd_wxBulidActivityId") if os.environ.get("jd_wxBulidActivityId") else ""
|
||||
|
||||
if not activityId:
|
||||
print("⚠️未发现有效盖楼有礼活动变量,退出程序!")
|
||||
sys.exit()
|
||||
activityUrl = f"https://lzkj-isv.isvjcloud.com/wxBuildActivity/activity?activityId={activityId}"
|
||||
|
||||
def redis_conn():
|
||||
try:
|
||||
import redis
|
||||
try:
|
||||
pool = redis.ConnectionPool(host=redis_url, port=redis_port, decode_responses=True, socket_connect_timeout=5, password=redis_pwd)
|
||||
r = redis.Redis(connection_pool=pool)
|
||||
r.get('conn_test')
|
||||
print('✅redis连接成功')
|
||||
return r
|
||||
except:
|
||||
print("⚠️redis连接异常")
|
||||
except:
|
||||
print("⚠️缺少redis依赖,请运行pip3 install redis")
|
||||
sys.exit()
|
||||
|
||||
def getToken(ck, r=None):
|
||||
host = f'{activityUrl.split("com/")[0]}com'
|
||||
try:
|
||||
# redis缓存Token 活动域名+pt_pin
|
||||
pt_pin = unquote_plus(re.compile(r'pt_pin=(.*?);').findall(ck)[0])
|
||||
except:
|
||||
# redis缓存Token 活动域名+ck前7位(获取pin失败)
|
||||
pt_pin = ck[:15]
|
||||
try:
|
||||
if r is not None:
|
||||
Token = r.get(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}')
|
||||
# print("Token过期时间", r.ttl(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}'))
|
||||
if Token is not None:
|
||||
print(f"♻️获取缓存Token")
|
||||
return Token
|
||||
else:
|
||||
# print("🈳去设置Token缓存")
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign_txt = sign({"url": f"{host}", "id": ""}, 'isvObfuscator')
|
||||
# print(sign_txt)
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
return
|
||||
Token_new = f.json()['token']
|
||||
# print(f"Token->: {Token_new}")
|
||||
if r.set(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}', Token_new, ex=1800):
|
||||
print("✅Token缓存成功")
|
||||
else:
|
||||
print("❌Token缓存失败")
|
||||
return Token_new
|
||||
else:
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign_txt = sign({"url": f"{host}", "id": ""}, 'isvObfuscator')
|
||||
# print(sign_txt)
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
return
|
||||
Token = f.json()['token']
|
||||
print(f"✅获取实时Token")
|
||||
return Token
|
||||
except:
|
||||
return
|
||||
|
||||
def getJdTime():
|
||||
jdTime = int(round(time.time() * 1000))
|
||||
return jdTime
|
||||
|
||||
def randomString(e, flag=False):
|
||||
t = "0123456789abcdef"
|
||||
if flag: t = t.upper()
|
||||
n = [random.choice(t) for _ in range(e)]
|
||||
return ''.join(n)
|
||||
|
||||
def refresh_cookies(res):
|
||||
if res.cookies:
|
||||
cookies = res.cookies.get_dict()
|
||||
set_cookie = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
global activityCookie
|
||||
activityCookieMid = [i for i in activityCookie.split(';') if i != '']
|
||||
for i in activityCookieMid:
|
||||
for x in set_cookie:
|
||||
if i.split('=')[0] == x.split('=')[0]:
|
||||
if i.split('=')[1] != x.split('=')[1]:
|
||||
activityCookieMid.remove(i)
|
||||
activityCookie = ''.join(sorted([(set_cookie + ";") for set_cookie in list(set(activityCookieMid + set_cookie))]))
|
||||
|
||||
def getActivity():
|
||||
url = f"https://lzkj-isv.isvjcloud.com/wxBuildActivity/activity?activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Connection': 'keep-alive'
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
if response.status_code == 200:
|
||||
if response.cookies:
|
||||
cookies = response.cookies.get_dict()
|
||||
set_cookies = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
set_cookie = ''.join(sorted([(set_cookie + ";") for set_cookie in set_cookies]))
|
||||
return set_cookie
|
||||
else:
|
||||
print(response.status_code, "⚠️疑似ip黑了")
|
||||
sys.exit()
|
||||
|
||||
def getSystemConfigForNew():
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxCommonInfo/getSystemConfigForNew"
|
||||
payload = f'activityId={activityId}&activityType=65'
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getSimpleActInfoVo():
|
||||
url = "https://lzkj-isv.isvjcloud.com/customer/getSimpleActInfoVo"
|
||||
payload = f"activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
|
||||
def getMyPing(venderId):
|
||||
url = "https://lzkj-isv.isvjcloud.com/customer/getMyPing"
|
||||
payload = f"userId={venderId}&token={token}&fromType=APP"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']['nickname'], res['data']['secretPin']
|
||||
else:
|
||||
print(f"⚠️{res['errorMessage']}")
|
||||
|
||||
def accessLogWithAD(venderId, pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/common/accessLogWithAD"
|
||||
payload = f"venderId={venderId}&code=65&pin={quote_plus(pin)}&activityId={activityId}&pageUrl={quote_plus(activityUrl)}&subType=app&adSource="
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def activityContent(pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxBuildActivity/activityContent"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};{activityCookie}'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
currentFloors = res['data']['currentFloors']
|
||||
totalJoinMans = res['data']['totalJoinMans']
|
||||
drawOkMans = res['data']['drawOkMans']
|
||||
drawInfos = res['data']['drawInfos']
|
||||
priceInfo = ' '.join([drawInfo['priceInfo'] for drawInfo in drawInfos])
|
||||
pricename = ' '.join([drawInfo['name'] for drawInfo in drawInfos])
|
||||
return currentFloors, totalJoinMans, drawOkMans, priceInfo, pricename
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
sys.exit()
|
||||
|
||||
def getShopInfoVO(venderId):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxActionCommon/getShopInfoVO"
|
||||
payload = f"userId={venderId}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
shopName = res['data']['shopName']
|
||||
return shopName
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
|
||||
def getActMemberInfo(venderId, pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxCommonInfo/getActMemberInfo"
|
||||
payload = f"venderId={venderId}&activityId={activityId}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
openCard = res['data']['openCard']
|
||||
return openCard
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
|
||||
def miniProgramShareInfo():
|
||||
url = f"https://lzkj-isv.isvjcloud.com/miniProgramShareInfo/getInfo?activityId={activityUrl}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getPublishs(pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxBuildActivity/getPublishs"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}&pageNo=1&pageSize=10"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};{activityCookie}'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def currentFloor(pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxBuildActivity/currentFloor"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}&pageNo=1&pageSize=10"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};{activityCookie}'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
currentFloors = res['data']['currentFloors']
|
||||
return currentFloors
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
|
||||
def publish(pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxBuildActivity/publish"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}&content={quote_plus('必中冲冲冲')}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};{activityCookie}'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
currentFloors = res['data']['currentFloors']
|
||||
drawInfo = res['data']['drawResult']['drawInfo']
|
||||
if drawInfo:
|
||||
print(f"🏗当前楼层{currentFloors} 🎉{drawInfo['name']}")
|
||||
return drawInfo['name']
|
||||
else:
|
||||
print(f"🏗当前楼层{currentFloors} 💨💨💨")
|
||||
return 2
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
return 3
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = redis_conn()
|
||||
try:
|
||||
cks = getCk
|
||||
if not cks:
|
||||
sys.exit()
|
||||
except:
|
||||
print("未获取到有效COOKIE,退出程序!")
|
||||
sys.exit()
|
||||
num = 0
|
||||
for cookie in cks[:]:
|
||||
num += 1
|
||||
if num % 9 == 0:
|
||||
print("⏰等待5s,休息一下")
|
||||
time.sleep(5)
|
||||
global ua, activityCookie, token
|
||||
ua = userAgent()
|
||||
try:
|
||||
pt_pin = re.compile(r'pt_pin=(.*?);').findall(cookie)[0]
|
||||
pt_pin = unquote_plus(pt_pin)
|
||||
except IndexError:
|
||||
pt_pin = f'用户{num}'
|
||||
print(f'\n******开始【京东账号{num}】{pt_pin} *********\n')
|
||||
print(datetime.now())
|
||||
token = getToken(cookie, r)
|
||||
if token is None:
|
||||
print(f"⚠️获取Token失败!⏰等待2s")
|
||||
time.sleep(2)
|
||||
continue
|
||||
time.sleep(0.2)
|
||||
activityCookie = getActivity()
|
||||
time.sleep(0.5)
|
||||
getSystemConfigForNew()
|
||||
time.sleep(0.2)
|
||||
getSimAct = getSimpleActInfoVo()
|
||||
venderId = getSimAct['venderId']
|
||||
time.sleep(0.2)
|
||||
getPin = getMyPing(venderId)
|
||||
if getPin is not None:
|
||||
nickname = getPin[0]
|
||||
secretPin = getPin[1]
|
||||
time.sleep(0.3)
|
||||
accessLogWithAD(venderId, secretPin)
|
||||
time.sleep(0.2)
|
||||
actCont = activityContent(secretPin)
|
||||
# currentFloors, totalJoinMans, drawOkMans, priceInfo, pricename
|
||||
if not actCont:
|
||||
continue
|
||||
currentFloors = actCont[0]
|
||||
totalJoinMans = actCont[1]
|
||||
drawOkMans = actCont[2]
|
||||
priceInfo = actCont[3]
|
||||
pricename = actCont[4]
|
||||
time.sleep(0.3)
|
||||
shopName = getShopInfoVO(venderId)
|
||||
if num == 1:
|
||||
print(f"✅开启{shopName}-盖楼有礼活动")
|
||||
print(f"🎁奖品{pricename}")
|
||||
time.sleep(0.2)
|
||||
getActMemberInfo(venderId, secretPin)
|
||||
time.sleep(0.2)
|
||||
miniProgramShareInfo()
|
||||
time.sleep(0.2)
|
||||
getPublishs(secretPin)
|
||||
time.sleep(0.2)
|
||||
currentFloor(secretPin)
|
||||
time.sleep(0.2)
|
||||
reward = publish(secretPin)
|
||||
if reward:
|
||||
if reward == 3:
|
||||
continue
|
||||
elif reward == 2:
|
||||
pass
|
||||
else:
|
||||
reward
|
||||
time.sleep(1)
|
||||
getPublishs(secretPin)
|
||||
time.sleep(0.2)
|
||||
currentFloor(secretPin)
|
||||
time.sleep(0.2)
|
||||
reward = publish(secretPin)
|
||||
if reward:
|
||||
if reward == 3:
|
||||
continue
|
||||
elif reward == 2:
|
||||
pass
|
||||
else:
|
||||
reward
|
||||
|
||||
time.sleep(5)
|
@ -1,646 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
File: jd_wxBulidActivity.py(加购有礼-监控脚本)
|
||||
Author: HarbourJ
|
||||
Date: 2022/9/18 19:52
|
||||
TG: https://t.me/HarbourToulu
|
||||
TgChat: https://t.me/HarbourSailing
|
||||
cron: 1 1 1 1 1 1
|
||||
new Env('加购有礼-JK')
|
||||
ActivityEntry: https://lzkj-isv.isvjd.com/wxCollectionActivity/activity2/df1bcc4c1e894444ae7579e124149999?activityId=df1bcc4c1e894444ae7579e124149999
|
||||
Description: 本地sign算法+redis缓存Token
|
||||
变量: export jd_wxCollectionActivityUrl="https://lzkj-isv.isvjd.com/wxCollectionActivity/activity2/xxx?activityId=xxx" 变量值需要传入完整活动地址
|
||||
"""
|
||||
|
||||
import time, requests, sys, re, os, json, random
|
||||
from datetime import datetime
|
||||
from sendNotify import *
|
||||
from urllib.parse import quote_plus, unquote_plus
|
||||
from functools import partial
|
||||
print = partial(print, flush=True)
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
try:
|
||||
from jd_sign import *
|
||||
except ImportError as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
print("请先运行Faker库依赖一键安装脚本(jd_check_dependent.py),安装jd_sign.so依赖")
|
||||
try:
|
||||
from jdCookie import get_cookies
|
||||
getCk = get_cookies()
|
||||
except:
|
||||
print("请先下载依赖脚本,\n下载链接: https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
|
||||
sys.exit(3)
|
||||
redis_url = os.environ.get("redis_url") if os.environ.get("redis_url") else "172.17.0.1"
|
||||
redis_port = os.environ.get("redis_port") if os.environ.get("redis_port") else "6379"
|
||||
redis_pwd = os.environ.get("redis_pwd") if os.environ.get("redis_pwd") else ""
|
||||
activity_url = os.environ.get("jd_wxCollectionActivityUrl") if os.environ.get("jd_wxCollectionActivityUrl") else ""
|
||||
runNums = os.environ.get("jd_wxCollectionActivityRunNums") if os.environ.get("jd_wxCollectionActivityRunNums") else 10
|
||||
|
||||
if not activity_url or "wxCollectionActivity/activity" not in activity_url:
|
||||
print("⚠️未发现有效加购有礼活动变量,退出程序!")
|
||||
sys.exit()
|
||||
activityUrl = activity_url.replace('isvjd', 'isvjcloud').split('&')[0]
|
||||
activityId = activityUrl.split('activityId=')[1]
|
||||
print(f"【🛳活动入口】{activityUrl}\n")
|
||||
runNums = int(runNums)
|
||||
if runNums == 10:
|
||||
print('🤖本次加购默认跑前10个账号,设置自定义变量:export jd_wxCollectionActivityRunNums="需要运行加购的ck数量"')
|
||||
else:
|
||||
print(f'🤖本次运行前{runNums}个账号')
|
||||
|
||||
|
||||
def redis_conn():
|
||||
try:
|
||||
import redis
|
||||
try:
|
||||
pool = redis.ConnectionPool(host=redis_url, port=redis_port, decode_responses=True, socket_connect_timeout=5, password=redis_pwd)
|
||||
r = redis.Redis(connection_pool=pool)
|
||||
r.get('conn_test')
|
||||
print('✅redis连接成功')
|
||||
return r
|
||||
except:
|
||||
print("⚠️redis连接异常")
|
||||
except:
|
||||
print("⚠️缺少redis依赖,请运行pip3 install redis")
|
||||
sys.exit()
|
||||
|
||||
def getToken(ck, r=None):
|
||||
host = f'{activityUrl.split("com/")[0]}com'
|
||||
try:
|
||||
# redis缓存Token 活动域名+pt_pin
|
||||
pt_pin = unquote_plus(re.compile(r'pt_pin=(.*?);').findall(ck)[0])
|
||||
except:
|
||||
# redis缓存Token 活动域名+ck前7位(获取pin失败)
|
||||
pt_pin = ck[:15]
|
||||
try:
|
||||
if r is not None:
|
||||
Token = r.get(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}')
|
||||
# print("Token过期时间", r.ttl(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}'))
|
||||
if Token is not None:
|
||||
print(f"♻️获取缓存Token")
|
||||
return Token
|
||||
else:
|
||||
# print("🈳去设置Token缓存")
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign_txt = sign({"url": f"{host}", "id": ""}, 'isvObfuscator')
|
||||
# print(sign_txt)
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
return
|
||||
Token_new = f.json()['token']
|
||||
# print(f"Token->: {Token_new}")
|
||||
if r.set(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}', Token_new, ex=1800):
|
||||
print("✅Token缓存成功")
|
||||
else:
|
||||
print("❌Token缓存失败")
|
||||
return Token_new
|
||||
else:
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign_txt = sign({"url": f"{host}", "id": ""}, 'isvObfuscator')
|
||||
# print(sign_txt)
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
return
|
||||
Token = f.json()['token']
|
||||
print(f"✅获取实时Token")
|
||||
return Token
|
||||
except:
|
||||
return
|
||||
|
||||
def getJdTime():
|
||||
jdTime = int(round(time.time() * 1000))
|
||||
return jdTime
|
||||
|
||||
def randomString(e, flag=False):
|
||||
t = "0123456789abcdef"
|
||||
if flag: t = t.upper()
|
||||
n = [random.choice(t) for _ in range(e)]
|
||||
return ''.join(n)
|
||||
|
||||
def refresh_cookies(res):
|
||||
if res.cookies:
|
||||
cookies = res.cookies.get_dict()
|
||||
set_cookie = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
global activityCookie
|
||||
activityCookieMid = [i for i in activityCookie.split(';') if i != '']
|
||||
for i in activityCookieMid:
|
||||
for x in set_cookie:
|
||||
if i.split('=')[0] == x.split('=')[0]:
|
||||
if i.split('=')[1] != x.split('=')[1]:
|
||||
activityCookieMid.remove(i)
|
||||
activityCookie = ''.join(sorted([(set_cookie + ";") for set_cookie in list(set(activityCookieMid + set_cookie))]))
|
||||
|
||||
def getActivity():
|
||||
url = activityUrl
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Connection': 'keep-alive'
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
if response.status_code == 200:
|
||||
if response.cookies:
|
||||
cookies = response.cookies.get_dict()
|
||||
set_cookies = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
set_cookie = ''.join(sorted([(set_cookie + ";") for set_cookie in set_cookies]))
|
||||
res = response.text
|
||||
if "活动已结束" in res:
|
||||
print("⛈活动已结束,下次早点来~")
|
||||
sys.exit()
|
||||
if "活动未开始" in res:
|
||||
print("⛈活动未开始~")
|
||||
sys.exit()
|
||||
if "关注" in res and "加购" not in res:
|
||||
activityType = 5
|
||||
else:
|
||||
activityType = 6
|
||||
return set_cookie, activityType
|
||||
else:
|
||||
print(response.status_code, "⚠️疑似ip黑了")
|
||||
msg += f'{response.status_code} ⚠️疑似ip黑了\n'
|
||||
sys.exit()
|
||||
|
||||
def getSystemConfigForNew(activityType):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxCommonInfo/getSystemConfigForNew"
|
||||
payload = f'activityId={activityId}&activityType={activityType}'
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getSimpleActInfoVo():
|
||||
url = "https://lzkj-isv.isvjcloud.com/customer/getSimpleActInfoVo"
|
||||
payload = f"activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
|
||||
def getMyPing(venderId):
|
||||
url = "https://lzkj-isv.isvjcloud.com/customer/getMyPing"
|
||||
payload = f"userId={venderId}&token={token}&fromType=APP"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
if response.status_code == 200:
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']['nickname'], res['data']['secretPin']
|
||||
else:
|
||||
print(f"⚠️{res['errorMessage']}")
|
||||
else:
|
||||
print(response.status_code, "⚠️疑似ip黑了")
|
||||
msg += f'{response.status_code} ⚠️疑似ip黑了\n'
|
||||
sys.exit()
|
||||
|
||||
def accessLogWithAD(venderId, pin, activityType):
|
||||
url = "https://lzkj-isv.isvjcloud.com/common/accessLogWithAD"
|
||||
payload = f"venderId={venderId}&code={activityType}&pin={quote_plus(pin)}&activityId={activityId}&pageUrl={quote_plus(activityUrl)}&subType=app&adSource="
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def activityContent(pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxCollectionActivity/activityContent"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
# refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
needCollectionSize = res['data']['needCollectionSize']
|
||||
hasCollectionSize = res['data']['hasCollectionSize']
|
||||
needFollow = res['data']['needFollow']
|
||||
hasFollow = res['data']['hasFollow']
|
||||
cpvos = res['data']['cpvos']
|
||||
drawInfo = res['data']['drawInfo']
|
||||
drawOk = drawInfo['drawOk']
|
||||
priceName = drawInfo['name']
|
||||
oneKeyAddCart = res['data']['oneKeyAddCart']
|
||||
return needCollectionSize, hasCollectionSize, needFollow, hasFollow, cpvos, drawOk, priceName, oneKeyAddCart
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
sys.exit()
|
||||
|
||||
def shopInfo():
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxCollectionActivity/shopInfo"
|
||||
payload = f"activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
shopName = res['data']['shopName']
|
||||
return shopName
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
|
||||
def getActMemberInfo(venderId, pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxCommonInfo/getActMemberInfo"
|
||||
payload = f"venderId={venderId}&activityId={activityId}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
# refresh_cookies(response)
|
||||
res = response.json()
|
||||
print(res)
|
||||
if res['result']:
|
||||
openCard = res['data']['openCard']
|
||||
return openCard
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
|
||||
def followShop(venderId, pin, activityType):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxActionCommon/followShop"
|
||||
payload = f"userId={venderId}&activityId={activityId}&buyerNick={quote_plus(pin)}&activityType={activityType}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
hasFollowShop = res['data']
|
||||
return hasFollowShop
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
if "店铺会员" in res['errorMessage']:
|
||||
return 99
|
||||
|
||||
def getInfo():
|
||||
url = f"https://lzkj-isv.isvjcloud.com/miniProgramShareInfo/getInfo?activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
refresh_cookies(response)
|
||||
|
||||
def addCard(productId, pin):
|
||||
"""加购"""
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxCollectionActivity/addCart"
|
||||
payload = f"productId={productId}&activityId={activityId}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
hasAddCartSize = res['data']['hasAddCartSize']
|
||||
return hasAddCartSize
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
|
||||
def collection(productId, pin):
|
||||
"""关注"""
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxCollectionActivity/collection"
|
||||
payload = f"productId={productId}&activityId={activityId}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
hasCollectionSize = res['data']['hasCollectionSize']
|
||||
return hasCollectionSize
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
|
||||
def oneKeyAdd(productIds, pin):
|
||||
"""一键加购"""
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxCollectionActivity/oneKeyAddCart"
|
||||
payload = f"productIds={productIds}&activityId={activityId}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
hasAddCartSize = res['data']['hasAddCartSize']
|
||||
return hasAddCartSize
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
|
||||
def getPrize(pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxCollectionActivity/getPrize"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};{activityCookie}'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
data = res['data']
|
||||
if data['drawOk']:
|
||||
priceName = data['name']
|
||||
return priceName
|
||||
else:
|
||||
errorMessage = data['errorMessage']
|
||||
print(f"⛈{errorMessage}")
|
||||
if "不足" in errorMessage:
|
||||
sys.exit()
|
||||
return errorMessage
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
if '奖品已发完' in res['errorMessage']:
|
||||
sys.exit()
|
||||
return res['errorMessage']
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
global msg
|
||||
msg = ''
|
||||
r = redis_conn()
|
||||
try:
|
||||
cks = getCk
|
||||
if not cks:
|
||||
sys.exit()
|
||||
except:
|
||||
print("未获取到有效COOKIE,退出程序!")
|
||||
sys.exit()
|
||||
num = 0
|
||||
for cookie in cks[:runNums]:
|
||||
num += 1
|
||||
if num % 5 == 0:
|
||||
print("⏰等待3s,休息一下")
|
||||
time.sleep(3)
|
||||
global ua, activityCookie, token
|
||||
ua = userAgent()
|
||||
try:
|
||||
pt_pin = re.compile(r'pt_pin=(.*?);').findall(cookie)[0]
|
||||
pt_pin = unquote_plus(pt_pin)
|
||||
except IndexError:
|
||||
pt_pin = f'用户{num}'
|
||||
print(f'\n******开始【京东账号{num}】{pt_pin} *********\n')
|
||||
print(datetime.now())
|
||||
token = getToken(cookie, r)
|
||||
if token is None:
|
||||
print(f"⚠️获取Token失败!⏰等待2s")
|
||||
time.sleep(2)
|
||||
continue
|
||||
time.sleep(0.3)
|
||||
getAct = getActivity()
|
||||
activityCookie = getAct[0]
|
||||
activityType = getAct[1]
|
||||
time.sleep(0.35)
|
||||
getSystemConfigForNew(activityType)
|
||||
time.sleep(0.35)
|
||||
getSimAct = getSimpleActInfoVo()
|
||||
venderId = getSimAct['venderId']
|
||||
time.sleep(0.35)
|
||||
getPin = getMyPing(venderId)
|
||||
if getPin is not None:
|
||||
nickname = getPin[0]
|
||||
secretPin = getPin[1]
|
||||
time.sleep(0.35)
|
||||
accessLogWithAD(venderId, secretPin, activityType)
|
||||
time.sleep(0.35)
|
||||
actCont = activityContent(secretPin)
|
||||
if not actCont:
|
||||
continue
|
||||
needCollectionSize = actCont[0]
|
||||
hasCollectionSize = actCont[1]
|
||||
needFollow = actCont[2]
|
||||
hasFollow = actCont[3]
|
||||
cpvos = actCont[4]
|
||||
drawOk = actCont[5]
|
||||
priceName = actCont[6]
|
||||
oneKeyAddCart = actCont[7]
|
||||
time.sleep(0.35)
|
||||
shopName = shopInfo()
|
||||
if num == 1:
|
||||
print(f"✅开启{shopName}-加购活动,需关注加购{needCollectionSize}个商品")
|
||||
print(f"🎁奖品{priceName}\n")
|
||||
msg += f'✅开启{shopName}-加购活动\n📝活动地址{activityUrl}\n🎁奖品{priceName}\n\n'
|
||||
if needCollectionSize <= hasCollectionSize:
|
||||
print("☃️已完成过加购任务,无法重复进行!")
|
||||
continue
|
||||
else:
|
||||
skuIds = [covo['skuId'] for covo in cpvos if not covo['collection']]
|
||||
time.sleep(0.2)
|
||||
getInfo()
|
||||
if needFollow:
|
||||
if not hasFollow:
|
||||
FS = followShop(venderId, secretPin, activityType)
|
||||
if FS == 99:
|
||||
continue
|
||||
time.sleep(0.35)
|
||||
addSkuNums = needCollectionSize - hasCollectionSize
|
||||
if oneKeyAddCart == 1:
|
||||
hasAddCartSize = oneKeyAdd(skuIds, secretPin)
|
||||
if hasAddCartSize:
|
||||
if hasAddCartSize == addSkuNums:
|
||||
print(f"🛳成功一键加购{hasAddCartSize}个商品")
|
||||
else:
|
||||
continue
|
||||
else:
|
||||
for productId in skuIds:
|
||||
if activityType == 6:
|
||||
hasAddCartSize = addCard(productId, secretPin)
|
||||
elif activityType == 5:
|
||||
hasAddCartSize = collection(productId, secretPin)
|
||||
time.sleep(0.25)
|
||||
if hasAddCartSize:
|
||||
if hasAddCartSize == addSkuNums:
|
||||
print(f"🛳成功加购{hasAddCartSize}个商品")
|
||||
break
|
||||
time.sleep(0.35)
|
||||
for i in range(3):
|
||||
priceName = getPrize(secretPin)
|
||||
if "擦肩" in priceName:
|
||||
time.sleep(0.2)
|
||||
continue
|
||||
else:
|
||||
break
|
||||
if "京豆" in priceName:
|
||||
print(f"🎉获得{priceName}")
|
||||
msg += f'【账号{num}】{pt_pin} 🎉{priceName}\n'
|
||||
elif "擦肩" in priceName:
|
||||
print(f"😭获得💨💨💨")
|
||||
else:
|
||||
pass
|
||||
|
||||
time.sleep(1.5)
|
||||
|
||||
title = "🗣消息提醒:加购有礼-JK"
|
||||
msg = f"⏰{str(datetime.now())[:19]}\n" + msg
|
||||
send(title, msg)
|
@ -1,579 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
File: jd_wxCompleteInfo.py(完善信息有礼-监控脚本)
|
||||
Author: HarbourJ
|
||||
Date: 2022/8/8 19:52
|
||||
TG: https://t.me/HarbourToulu
|
||||
TgChat: https://t.me/HarbourSailing
|
||||
cron: 1 1 1 1 1 1
|
||||
new Env('完善信息有礼-JK');
|
||||
ActivityEntry: https://cjhy-isv.isvjcloud.com/wx/completeInfoActivity/view/activity?activityId=f3325e3375a14866xxxxxxxxxxxx&venderId=1000086
|
||||
变量 export jd_wxCompleteInfoId="f3325e3375a14866xxxxxxxxxxxx&1000086192"(活动id&venderId)
|
||||
"""
|
||||
|
||||
import time, requests, sys, re, os, json, random
|
||||
from datetime import datetime
|
||||
from urllib.parse import quote_plus, unquote_plus
|
||||
from functools import partial
|
||||
print = partial(print, flush=True)
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
try:
|
||||
from jd_sign import *
|
||||
except ImportError as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
print("请先运行Faker库依赖一键安装脚本(jd_check_dependent.py),安装jd_sign.so依赖")
|
||||
try:
|
||||
from jdCookie import get_cookies
|
||||
getCk = get_cookies()
|
||||
except:
|
||||
print("请先下载依赖脚本,\n下载链接: https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
|
||||
sys.exit(3)
|
||||
redis_url = os.environ.get("redis_url") if os.environ.get("redis_url") else "172.17.0.1"
|
||||
redis_port = os.environ.get("redis_port") if os.environ.get("redis_port") else "6379"
|
||||
redis_pwd = os.environ.get("redis_pwd") if os.environ.get("redis_pwd") else ""
|
||||
jd_wxCompleteInfoId = os.environ.get("jd_wxCompleteInfoId") if os.environ.get("jd_wxCompleteInfoId") else ""
|
||||
|
||||
if not jd_wxCompleteInfoId or "&" not in jd_wxCompleteInfoId:
|
||||
print("⚠️未发现有效活动变量jd_wxCompleteInfoId,退出程序!")
|
||||
sys.exit()
|
||||
activityId = jd_wxCompleteInfoId.split('&')[0]
|
||||
venderId = jd_wxCompleteInfoId.split('&')[1]
|
||||
|
||||
activityUrl = f"https://cjhy-isv.isvjcloud.com/wx/completeInfoActivity/view/activity?activityId={activityId}&venderId={venderId}"
|
||||
print(f"【🛳活动入口】{activityUrl}")
|
||||
|
||||
def redis_conn():
|
||||
try:
|
||||
try:
|
||||
import redis
|
||||
except Exception as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
os.system("pip install redis")
|
||||
import redis
|
||||
try:
|
||||
pool = redis.ConnectionPool(host=redis_url, port=redis_port, decode_responses=True, socket_connect_timeout=5, password=redis_pwd)
|
||||
r = redis.Redis(connection_pool=pool)
|
||||
r.get('conn_test')
|
||||
print('✅redis连接成功')
|
||||
return r
|
||||
except:
|
||||
print("⚠️redis连接异常")
|
||||
except:
|
||||
print("⚠️缺少redis依赖,请运行pip3 install redis")
|
||||
sys.exit()
|
||||
|
||||
def getToken(ck, r=None):
|
||||
host = f'{activityUrl.split("com/")[0]}com'
|
||||
try:
|
||||
# redis缓存Token 活动域名+pt_pin
|
||||
pt_pin = unquote_plus(re.compile(r'pt_pin=(.*?);').findall(ck)[0])
|
||||
except:
|
||||
# redis缓存Token 活动域名+ck前7位(获取pin失败)
|
||||
pt_pin = ck[:15]
|
||||
try:
|
||||
if r is not None:
|
||||
Token = r.get(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}')
|
||||
# print("Token过期时间", r.ttl(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}'))
|
||||
if Token is not None:
|
||||
print(f"♻️获取缓存Token")
|
||||
return Token
|
||||
else:
|
||||
# print("🈳去设置Token缓存")
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign_txt = sign({"url": f"{host}", "id": ""}, 'isvObfuscator')
|
||||
# print(sign_txt)
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
return
|
||||
Token_new = f.json()['token']
|
||||
# print(f"Token->: {Token_new}")
|
||||
if r.set(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}', Token_new, ex=1800):
|
||||
print("✅Token缓存成功")
|
||||
else:
|
||||
print("❌Token缓存失败")
|
||||
return Token_new
|
||||
else:
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign_txt = sign({"url": f"{host}", "id": ""}, 'isvObfuscator')
|
||||
# print(sign_txt)
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
return
|
||||
Token = f.json()['token']
|
||||
print(f"✅获取实时Token")
|
||||
return Token
|
||||
except:
|
||||
return
|
||||
|
||||
def getJdTime():
|
||||
jdTime = int(round(time.time() * 1000))
|
||||
return jdTime
|
||||
|
||||
def randomString(e, flag=False):
|
||||
t = "0123456789abcdef"
|
||||
if flag: t = t.upper()
|
||||
n = [random.choice(t) for _ in range(e)]
|
||||
return ''.join(n)
|
||||
|
||||
def refresh_cookies(res):
|
||||
if res.cookies:
|
||||
cookies = res.cookies.get_dict()
|
||||
set_cookie = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
global activityCookie
|
||||
activityCookieMid = [i for i in activityCookie.split(';') if i != '']
|
||||
for i in activityCookieMid:
|
||||
for x in set_cookie:
|
||||
if i.split('=')[0] == x.split('=')[0]:
|
||||
if i.split('=')[1] != x.split('=')[1]:
|
||||
activityCookieMid.remove(i)
|
||||
activityCookie = ''.join(sorted([(set_cookie + ";") for set_cookie in list(set(activityCookieMid + set_cookie))]))
|
||||
|
||||
def getActivity():
|
||||
url = activityUrl
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Connection': 'keep-alive'
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
if response.status_code == 200:
|
||||
if response.cookies:
|
||||
cookies = response.cookies.get_dict()
|
||||
set_cookies = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
set_cookie = ''.join(sorted([(set_cookie + ";") for set_cookie in set_cookies]))
|
||||
return set_cookie
|
||||
else:
|
||||
print(response.status_code)
|
||||
print("⚠️疑似ip黑了")
|
||||
sys.exit()
|
||||
|
||||
def getOpenStatus():
|
||||
url = "https://cjhy-isv.isvjcloud.com/assembleConfig/getOpenStatus"
|
||||
payload = f'activityId={activityId}'
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
def getSystemConfig():
|
||||
url = "https://cjhy-isv.isvjcloud.com/wxCommonInfo/getSystemConfig"
|
||||
payload = f'activityId={activityId}&activityType='
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getSimpleActInfoVo():
|
||||
url = "https://cjhy-isv.isvjcloud.com/customer/getSimpleActInfoVo"
|
||||
payload = f"activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def getMyPing(venderId):
|
||||
url = "https://cjhy-isv.isvjcloud.com/customer/getMyPing"
|
||||
payload = f"userId={venderId}&token={token}&fromType=APP&riskType=1"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
if response.status_code == 200:
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']['nickname'], res['data']['secretPin']
|
||||
else:
|
||||
print(f"⚠️{res['errorMessage']}")
|
||||
else:
|
||||
print(response.status_code)
|
||||
print("⚠️疑似ip黑了")
|
||||
sys.exit()
|
||||
|
||||
def _selectById(venderId):
|
||||
url = "https://cjhy-isv.isvjcloud.com/completeInfoActivity/selectById"
|
||||
body = f"activityId={activityId}&venderId={venderId}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=body)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
saveInfo = ""
|
||||
data = res['data']
|
||||
chooseName = data['chooseName']
|
||||
choosePhone = data['choosePhone']
|
||||
chooseBirth = data['chooseBirth']
|
||||
chooseWeixin = data['chooseWeixin']
|
||||
chooseAddress = data['chooseAddress']
|
||||
chooseQQ = data['chooseQQ']
|
||||
chooseEmail = data['chooseEmail']
|
||||
chooseGender = data['chooseGender']
|
||||
chooseProfessional = data['chooseProfessional']
|
||||
customJson = data['customJson']
|
||||
phone = get_mobile()
|
||||
if chooseName == 'y':
|
||||
name = quote_plus(f"{random.choice(['A','B','C','D','E','F','G','H'])}贤笙")
|
||||
saveInfo += f"name={name}&"
|
||||
if choosePhone == 'y':
|
||||
saveInfo += f"phone={phone}&"
|
||||
if chooseBirth == 'y':
|
||||
birthDay = "2000-01-01"
|
||||
saveInfo += f"birthDay={birthDay}&"
|
||||
if chooseWeixin == 'y':
|
||||
weiXin = phone
|
||||
saveInfo += f"weiXin={weiXin}&"
|
||||
if chooseEmail == 'y':
|
||||
email = quote_plus(f"{phone}@163.com")
|
||||
saveInfo += f"email={email}&"
|
||||
if chooseGender == 'y':
|
||||
gender = quote_plus("男")
|
||||
saveInfo += f"gender={gender}&"
|
||||
if chooseProfessional == 'y':
|
||||
professional = "Engineer"
|
||||
saveInfo += f"professional={professional}&"
|
||||
if chooseQQ == 'y':
|
||||
qq = phone
|
||||
saveInfo += f"{qq}&"
|
||||
if chooseAddress == 'y':
|
||||
province = quote_plus("北京市")
|
||||
city = quote_plus("东城区")
|
||||
address = quote_plus("北京大学城北门")
|
||||
saveInfo += f"province={province}&city={city}&address={address}&"
|
||||
if customJson != "[]":
|
||||
customContent = "%5B%2222%22%5D"
|
||||
saveInfo += f"customContent={customContent}&"
|
||||
return saveInfo
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def getOpenCardInfo(venderId, pin, activityType):
|
||||
url = "https://cjhy-isv.isvjcloud.com/mc/new/brandCard/common/shopAndBrand/getOpenCardInfo"
|
||||
body = f"venderId={venderId}&buyerPin={pin}&activityType={activityType}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=body)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def getShopInfoVO(venderId):
|
||||
url = "https://cjhy-isv.isvjcloud.com/wxActionCommon/getShopInfoVO"
|
||||
payload = f"userId={venderId}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
def accessLog(venderId, pin, activityType):
|
||||
url = "https://cjhy-isv.isvjcloud.com/common/accessLog"
|
||||
payload = f"venderId={venderId}&code={activityType}&pin={quote_plus(pin)}&activityId={activityId}&pageUrl={quote_plus(activityUrl)}&subType="
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
def listDrawContent(activityType):
|
||||
url = "https://cjhy-isv.isvjcloud.com/drawContent/listDrawContent"
|
||||
body = f"activityId={activityId}&type={activityType}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=body)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
# print(res['errorMessage'])
|
||||
if "暂未填写" in res['errorMessage']:
|
||||
print("📝现在去完善信息")
|
||||
|
||||
def selectById(pin, venderId):
|
||||
url = "https://cjhy-isv.isvjcloud.com/wx/completeInfoActivity/selectById"
|
||||
body = f"activityId={activityId}&pin={quote_plus(pin)}&venderId={venderId}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=body)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
# print(res['errorMessage'])
|
||||
if "暂未填写" in res['errorMessage']:
|
||||
print("📝现在去完善会员信息")
|
||||
|
||||
def getInfo():
|
||||
url = f"https://cjhy-isv.isvjcloud.com/miniProgramShareInfo/getInfo?activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Connection': 'keep-alive',
|
||||
'Accept': 'application/json',
|
||||
'User-Agent': ua,
|
||||
'Referer': activityUrl,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Cookie': activityCookie,
|
||||
}
|
||||
requests.request("GET", url, headers=headers)
|
||||
|
||||
def get_mobile():
|
||||
mobiles = ['130', '131', '132', '133', '134']
|
||||
number = str(int(time.time()))[2:]
|
||||
mobile = random.choice(mobiles)+number
|
||||
return mobile
|
||||
|
||||
def save(saveInfo, venderId, pin, drawInfoId):
|
||||
url = "https://cjhy-isv.isvjcloud.com/wx/completeInfoActivity/save"
|
||||
body = f"{saveInfo}drawInfoId={drawInfoId}&activityId={activityId}&venderId={venderId}&pin={quote_plus(pin)}&vcode=&token={token}&fromType=APP"
|
||||
headers = {
|
||||
'Host': 'cjhy-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://cjhy-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=body)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
else:
|
||||
print(res['errorMessage'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = redis_conn()
|
||||
try:
|
||||
cks = getCk
|
||||
if not cks:
|
||||
sys.exit()
|
||||
except:
|
||||
print("未获取到有效COOKIE,退出程序!")
|
||||
sys.exit()
|
||||
num = 0
|
||||
for cookie in cks[:]:
|
||||
num += 1
|
||||
if num % 9 == 0:
|
||||
print("⏰等待5s,休息一下")
|
||||
time.sleep(5)
|
||||
global ua, activityCookie, token
|
||||
ua = userAgent()
|
||||
try:
|
||||
pt_pin = re.compile(r'pt_pin=(.*?);').findall(cookie)[0]
|
||||
pt_pin = unquote_plus(pt_pin)
|
||||
except IndexError:
|
||||
pt_pin = f'用户{num}'
|
||||
print(f'\n******开始【京东账号{num}】{pt_pin} *********\n')
|
||||
print(datetime.now())
|
||||
token = getToken(cookie, r)
|
||||
if token is None:
|
||||
print(f"⚠️获取Token失败!⏰等待2s")
|
||||
time.sleep(2)
|
||||
continue
|
||||
time.sleep(0.2)
|
||||
activityCookie = getActivity()
|
||||
time.sleep(0.3)
|
||||
getOpenStatus()
|
||||
time.sleep(0.1)
|
||||
getSimAct = getSimpleActInfoVo()
|
||||
venderId = getSimAct['venderId']
|
||||
activityType = getSimAct['activityType']
|
||||
time.sleep(0.2)
|
||||
getPin = getMyPing(venderId)
|
||||
if getPin:
|
||||
nickname = getPin[0]
|
||||
secretPin = getPin[1]
|
||||
time.sleep(0.2)
|
||||
getOC = getOpenCardInfo(venderId, secretPin, activityType)
|
||||
time.sleep(0.1)
|
||||
if getOC['openedCard']:
|
||||
getShopInfo = getShopInfoVO(venderId)
|
||||
shopName = getShopInfo['shopName']
|
||||
print(f"✅开启{shopName} 店铺完善会员信息有礼")
|
||||
accessLog(venderId, secretPin, activityType)
|
||||
time.sleep(0.2)
|
||||
saveInfo = _selectById(venderId)
|
||||
time.sleep(0.2)
|
||||
selectBI = selectById(secretPin, venderId)
|
||||
if selectBI:
|
||||
print(f"💨{nickname} 已经完善过店铺信息")
|
||||
continue
|
||||
else:
|
||||
time.sleep(0.2)
|
||||
listDraw = listDrawContent(activityType)
|
||||
drawInfoId = listDraw[0]['drawInfoId']
|
||||
time.sleep(0.2)
|
||||
getInfo()
|
||||
time.sleep(0.1)
|
||||
sv = save(saveInfo, venderId, secretPin, drawInfoId)
|
||||
if sv:
|
||||
drawInfo = sv['drawInfo']['name']
|
||||
if drawInfo:
|
||||
print(f"🎉🎉🎉{nickname} 成功领取 {drawInfo}")
|
||||
else:
|
||||
print(f"⛈⛈⛈{nickname} 领取完善有礼奖励失败,请重试~")
|
||||
else:
|
||||
print(f"💨{nickname} 已经领过完善有礼奖励~")
|
||||
else:
|
||||
print(f"⛈{nickname} 非店铺会员无法完善信息!")
|
||||
continue
|
||||
time.sleep(2.5)
|
@ -1,550 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
File: jd_wxShopFollowActivity.py(关注店铺有礼-JK)
|
||||
Author: HarbourJ
|
||||
Date: 2022/8/8 19:52
|
||||
TG: https://t.me/HarbourToulu
|
||||
cron: 1 1 1 1 1 *
|
||||
new Env('关注店铺有礼-JK');
|
||||
ActivityEntry: https://lzkj-isv.isvjcloud.com/wxShopFollowActivity/activity?activityId=3d6dbfd9c8584be882f69cfad665ce8d
|
||||
变量 export jd_wxShopFollowId="活动🆔"
|
||||
export jd_wxShopFollowRunNums="变量为需要运行账号数量" # 默认前12个账号
|
||||
"""
|
||||
|
||||
import time, requests, sys, re, os, json, random
|
||||
from datetime import datetime
|
||||
from sendNotify import *
|
||||
from urllib.parse import quote_plus, unquote_plus
|
||||
from functools import partial
|
||||
print = partial(print, flush=True)
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
try:
|
||||
from jd_sign import *
|
||||
except ImportError as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
print("请先运行Faker库依赖一键安装脚本(jd_check_dependent.py),安装jd_sign.so依赖")
|
||||
sys.exit()
|
||||
try:
|
||||
from jdCookie import get_cookies
|
||||
getCk = get_cookies()
|
||||
except:
|
||||
print("请先下载依赖脚本,\n下载链接: https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
|
||||
sys.exit(3)
|
||||
|
||||
redis_url = os.environ.get("redis_url") if os.environ.get("redis_url") else "172.17.0.1"
|
||||
redis_port = os.environ.get("redis_port") if os.environ.get("redis_port") else "6379"
|
||||
redis_pwd = os.environ.get("redis_pwd") if os.environ.get("redis_pwd") else ""
|
||||
activityId = os.environ.get("jd_wxShopFollowId") if os.environ.get("jd_wxShopFollowId") else ""
|
||||
runNums = os.environ.get("jd_wxShopFollowRunNums") if os.environ.get("jd_wxShopFollowRunNums") else 12
|
||||
|
||||
if not activityId:
|
||||
print("⚠️未发现有效活动变量,退出程序!")
|
||||
sys.exit()
|
||||
|
||||
runNums = int(runNums)
|
||||
if runNums == 12:
|
||||
print('🤖本次关注默认跑前12个账号,设置自定义变量:export jd_wxShopFollowRunNums="需要运行的ck数量"')
|
||||
else:
|
||||
print(f'🤖本次运行前{runNums}个账号')
|
||||
|
||||
activityUrl = f"https://lzkj-isv.isvjd.com/wxShopFollowActivity/activity?activityId={activityId}"
|
||||
|
||||
def redis_conn():
|
||||
try:
|
||||
import redis
|
||||
try:
|
||||
pool = redis.ConnectionPool(host=redis_url, port=6379, decode_responses=True, socket_connect_timeout=5, password=redis_pwd)
|
||||
r = redis.Redis(connection_pool=pool)
|
||||
r.get('conn_test')
|
||||
print('✅redis连接成功')
|
||||
return r
|
||||
except:
|
||||
print("⚠️redis连接异常")
|
||||
except:
|
||||
print("⚠️缺少redis依赖,请运行pip3 install redis")
|
||||
sys.exit()
|
||||
|
||||
def getToken(ck, r=None):
|
||||
host = f'{activityUrl.split("com/")[0]}com'
|
||||
try:
|
||||
pt_pin = unquote_plus(re.compile(r'pt_pin=(.*?);').findall(ck)[0])
|
||||
except:
|
||||
pt_pin = ck[:15]
|
||||
try:
|
||||
try:
|
||||
Token = r.get(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}')
|
||||
except Exception as e:
|
||||
# print(f"redis get error: {str(e)}")
|
||||
Token = None
|
||||
if Token is not None:
|
||||
print(f"♻️获取缓存Token")
|
||||
return Token
|
||||
else:
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign({"url": f"{host}", "id": ""}, 'isvObfuscator')
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
print(f.text)
|
||||
return
|
||||
Token_new = f.json()['token']
|
||||
try:
|
||||
if r.set(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}', Token_new, ex=1800):
|
||||
print("✅Token缓存成功")
|
||||
else:
|
||||
print("❌Token缓存失败")
|
||||
except Exception as e:
|
||||
# print(f"redis set error: {str(e)}")
|
||||
print(f"✅获取实时Token")
|
||||
return Token_new
|
||||
except Exception as e:
|
||||
print(f"Token error: {str(e)}")
|
||||
return
|
||||
|
||||
def getJdTime():
|
||||
jdTime = int(round(time.time() * 1000))
|
||||
return jdTime
|
||||
|
||||
def randomString(e, flag=False):
|
||||
t = "0123456789abcdef"
|
||||
if flag: t = t.upper()
|
||||
n = [random.choice(t) for _ in range(e)]
|
||||
return ''.join(n)
|
||||
|
||||
def refresh_cookies(res):
|
||||
if res.cookies:
|
||||
cookies = res.cookies.get_dict()
|
||||
set_cookie = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
global activityCookie
|
||||
activityCookieMid = [i for i in activityCookie.split(';') if i != '']
|
||||
for i in activityCookieMid:
|
||||
for x in set_cookie:
|
||||
if i.split('=')[0] == x.split('=')[0]:
|
||||
if i.split('=')[1] != x.split('=')[1]:
|
||||
activityCookieMid.remove(i)
|
||||
activityCookie = ''.join(sorted([(set_cookie + ";") for set_cookie in list(set(activityCookieMid + set_cookie))]))
|
||||
|
||||
def getActivity():
|
||||
url = f"https://lzkj-isv.isvjcloud.com/wxShopFollowActivity/activity?activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Connection': 'keep-alive'
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
if response.status_code == 200:
|
||||
if response.cookies:
|
||||
cookies = response.cookies.get_dict()
|
||||
set_cookies = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
set_cookie = ''.join(sorted([(set_cookie + ";") for set_cookie in set_cookies]))
|
||||
return set_cookie
|
||||
else:
|
||||
print(response.status_code)
|
||||
print("⚠️疑似ip黑了")
|
||||
sys.exit()
|
||||
|
||||
def getSystemConfigForNew():
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxCommonInfo/getSystemConfigForNew"
|
||||
payload = f'activityId={activityId}&activityType=17'
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getSimpleActInfoVo():
|
||||
url = "https://lzkj-isv.isvjcloud.com/customer/getSimpleActInfoVo"
|
||||
payload = f"activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
|
||||
def getMyPing(venderId):
|
||||
url = "https://lzkj-isv.isvjcloud.com/customer/getMyPing"
|
||||
payload = f"userId={venderId}&token={token}&fromType=APP"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']['nickname'], res['data']['secretPin']
|
||||
else:
|
||||
print(f"⚠️{res['errorMessage']}")
|
||||
|
||||
def accessLogWithAD(venderId, pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/common/accessLogWithAD"
|
||||
payload = f"venderId={venderId}&code=17&pin={quote_plus(pin)}&activityId={activityId}&pageUrl={quote_plus(activityUrl)}&subType=app&adSource="
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def activityContentOnly(pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxShopFollowActivity/activityContentOnly"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};{activityCookie}'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
canJoin = res['data']['canJoin']
|
||||
drawContentVOs = res['data']['drawContentVOs']
|
||||
# if not canJoin:
|
||||
# print("⛈活动已结束,下次早点来~")
|
||||
# sys.exit()
|
||||
name = drawContentVOs[0]['name']
|
||||
hasSendPrizeNum = drawContentVOs[0]['hasSendPrizeNum']
|
||||
prizeNum = drawContentVOs[0]['prizeNum']
|
||||
canDrawTimes = res['data']['canDrawTimes']
|
||||
needFollow = res['data']['needFollow']
|
||||
hasFollow = res['data']['hasFollow']
|
||||
return name, hasSendPrizeNum, prizeNum, canDrawTimes, needFollow, hasFollow
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
sys.exit()
|
||||
|
||||
def shopInfo():
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxShopFollowActivity/shopInfo"
|
||||
payload = f"activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
shopName = res['data']['shopName']
|
||||
return shopName
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
|
||||
def getActMemberInfo(venderId, pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxCommonInfo/getActMemberInfo"
|
||||
payload = f"venderId={venderId}&activityId={activityId}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
print(res)
|
||||
if res['result']:
|
||||
openCard = res['data']['openCard']
|
||||
return openCard
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
|
||||
def followShop(pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxShopFollowActivity/follow"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
pass
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
if "店铺会员" in res['errorMessage']:
|
||||
return 99
|
||||
|
||||
def getInfo():
|
||||
url = f"https://lzkj-isv.isvjcloud.com/miniProgramShareInfo/getInfo?activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getPrize(pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxShopFollowActivity/getPrize"
|
||||
payload = f"activityId={activityId}&pin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};{activityCookie}'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
data = res['data']
|
||||
if data['drawOk']:
|
||||
priceName = data['name']
|
||||
return priceName
|
||||
else:
|
||||
if data['canDrawTimes'] > 0:
|
||||
return 9
|
||||
else:
|
||||
return 99
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
if '奖品已发完' in res['errorMessage']:
|
||||
sys.exit()
|
||||
return res['errorMessage']
|
||||
|
||||
def bindWithVender(cookie, venderId):
|
||||
try:
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': ua,
|
||||
'Cookie': cookie,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': 'https://shopmember.m.jd.com/',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
s.params = {
|
||||
'appid': 'jd_shop_member',
|
||||
'functionId': 'bindWithVender',
|
||||
'body': json.dumps({
|
||||
'venderId': venderId,
|
||||
'shopId': venderId,
|
||||
'bindByVerifyCodeFlag': 1
|
||||
}, separators=(',', ':'))
|
||||
}
|
||||
res = s.post('https://api.m.jd.com/', verify=False, timeout=30).json()
|
||||
if res['success']:
|
||||
return res['message'], res['result']['giftInfo']
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
global msg
|
||||
msg = ''
|
||||
r = redis_conn()
|
||||
try:
|
||||
cks = getCk
|
||||
if not cks:
|
||||
sys.exit()
|
||||
except:
|
||||
print("未获取到有效COOKIE,退出程序!")
|
||||
sys.exit()
|
||||
num = 0
|
||||
for cookie in cks[:runNums]:
|
||||
num += 1
|
||||
if num % 6 == 0:
|
||||
print("⏰等待5s,休息一下")
|
||||
time.sleep(5)
|
||||
global ua, activityCookie, token
|
||||
ua = userAgent()
|
||||
try:
|
||||
pt_pin = re.compile(r'pt_pin=(.*?);').findall(cookie)[0]
|
||||
pt_pin = unquote_plus(pt_pin)
|
||||
except IndexError:
|
||||
pt_pin = f'用户{num}'
|
||||
print(f'\n******开始【京东账号{num}】{pt_pin} *********\n')
|
||||
print(datetime.now())
|
||||
|
||||
token = getToken(cookie, r)
|
||||
if token is None:
|
||||
print(f"⚠️获取Token失败!⏰等待2s")
|
||||
time.sleep(2)
|
||||
continue
|
||||
time.sleep(0.2)
|
||||
activityCookie = getActivity()
|
||||
time.sleep(0.2)
|
||||
getSystemConfigForNew()
|
||||
time.sleep(0.2)
|
||||
getSimAct = getSimpleActInfoVo()
|
||||
venderId = getSimAct['venderId']
|
||||
time.sleep(0.2)
|
||||
getPin = getMyPing(venderId)
|
||||
if getPin is not None:
|
||||
nickname = getPin[0]
|
||||
secretPin = getPin[1]
|
||||
time.sleep(0.3)
|
||||
accessLogWithAD(venderId, secretPin)
|
||||
time.sleep(0.3)
|
||||
actContent = activityContentOnly(secretPin)
|
||||
# name, hasSendPrizeNum, prizeNum, canDrawTimes, needFollow, hasFollow
|
||||
if not actContent:
|
||||
continue
|
||||
priceName = actContent[0]
|
||||
hasSendPrizeNum = actContent[1]
|
||||
prizeNum = actContent[2]
|
||||
canDrawTimes = actContent[3]
|
||||
needFollow = actContent[4]
|
||||
hasFollow = actContent[5]
|
||||
time.sleep(0.15)
|
||||
shopName = shopInfo()
|
||||
if num == 1:
|
||||
print(f"✅开启{shopName}-关注店铺有礼活动")
|
||||
print(f"🎁奖品{priceName}\n")
|
||||
msg += f'✅开启{shopName}-关注店铺有礼活动\n📝活动地址{activityUrl}\n🎁奖品{priceName}\n\n'
|
||||
print(f"🎁共{prizeNum}份, 剩余{prizeNum-hasSendPrizeNum}份")
|
||||
if hasSendPrizeNum == prizeNum:
|
||||
print("⛈礼品已领完")
|
||||
sys.exit()
|
||||
if canDrawTimes == 0:
|
||||
print("🤖已参加过本活动")
|
||||
time.sleep(1.5)
|
||||
continue
|
||||
time.sleep(0.2)
|
||||
getInfo()
|
||||
if needFollow:
|
||||
if not hasFollow:
|
||||
FS = followShop(secretPin)
|
||||
if FS == 99:
|
||||
time.sleep(0.2)
|
||||
open_result = bindWithVender(cookie, venderId)
|
||||
if open_result is not None:
|
||||
if "火爆" in open_result[0] or "失败" in open_result[0] or "解绑" in open_result[0]:
|
||||
print(f"⛈{open_result[0]}")
|
||||
time.sleep(1.5)
|
||||
continue
|
||||
if "加入店铺会员成功" in open_result[0]:
|
||||
print(f"\t💳{shopName} {open_result[0]}")
|
||||
if open_result[1]:
|
||||
print(f"\t🎁获得{','.join([gift['discountString'] + gift['prizeName'] for gift in open_result[1]['giftList']])}")
|
||||
time.sleep(0.2)
|
||||
followShop(secretPin)
|
||||
time.sleep(0.15)
|
||||
for i in range(3):
|
||||
priceName = getPrize(secretPin)
|
||||
if priceName == 9:
|
||||
time.sleep(0.2)
|
||||
continue
|
||||
else:
|
||||
break
|
||||
if "火爆" in str(priceName) or priceName == 99 or priceName is None:
|
||||
print(f"😭获得💨💨💨")
|
||||
else:
|
||||
print(f"🎉获得{priceName}")
|
||||
msg += f'【账号{num}】{pt_pin} 🎉{priceName}\n'
|
||||
|
||||
time.sleep(1.5)
|
||||
|
||||
title = "🗣消息提醒:关注店铺有礼-JK"
|
||||
msg = f"⏰{str(datetime.now())[:19]}\n" + msg
|
||||
send(title, msg)
|
395
jd_wxShopGift.py
395
jd_wxShopGift.py
@ -1,395 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
File: jd_wxShopGift.py(店铺特效关注有礼-监控脚本)
|
||||
Author: HarbourJ
|
||||
Date: 2022/8/8 19:52
|
||||
TG: https://t.me/HarbourToulu
|
||||
TgChat: https://t.me/HarbourSailing
|
||||
cron: 1 1 1 1 1 1
|
||||
new Env('店铺特效关注有礼-JK');
|
||||
ActivityEntry: https://lzkj-isv.isvjcloud.com/wxShopGift/activity?activityId=971e85d5dfd445e1acfc63bafffb8ecc
|
||||
变量 export jd_wxShopGiftId="971e85d5dfd445e1axxxxxxxxxxxx"
|
||||
"""
|
||||
|
||||
import time, requests, sys, re, os, json, random
|
||||
from datetime import datetime
|
||||
from urllib.parse import quote_plus, unquote_plus
|
||||
from functools import partial
|
||||
print = partial(print, flush=True)
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
try:
|
||||
from jd_sign import *
|
||||
except ImportError as e:
|
||||
print(e)
|
||||
if "No module" in str(e):
|
||||
print("请先运行Faker库依赖一键安装脚本(jd_check_dependent.py),安装jd_sign.so依赖")
|
||||
try:
|
||||
from jdCookie import get_cookies
|
||||
getCk = get_cookies()
|
||||
except:
|
||||
print("请先下载依赖脚本,\n下载链接: https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
|
||||
sys.exit(3)
|
||||
redis_url = os.environ.get("redis_url") if os.environ.get("redis_url") else "172.17.0.1"
|
||||
redis_port = os.environ.get("redis_port") if os.environ.get("redis_port") else "6379"
|
||||
redis_pwd = os.environ.get("redis_pwd") if os.environ.get("redis_pwd") else ""
|
||||
activityId = os.environ.get("jd_wxShopGiftId") if os.environ.get("jd_wxShopGiftId") else ""
|
||||
|
||||
if not activityId:
|
||||
print("⚠️未发现有效活动变量,退出程序!")
|
||||
sys.exit()
|
||||
activityUrl = f"https://lzkj-isv.isvjcloud.com/wxShopGift/activity?activityId={activityId}"
|
||||
|
||||
def redis_conn():
|
||||
try:
|
||||
import redis
|
||||
try:
|
||||
pool = redis.ConnectionPool(host=redis_url, port=redis_port, decode_responses=True, socket_connect_timeout=5, password=redis_pwd)
|
||||
r = redis.Redis(connection_pool=pool)
|
||||
r.get('conn_test')
|
||||
print('✅redis连接成功')
|
||||
return r
|
||||
except:
|
||||
print("⚠️redis连接异常")
|
||||
except:
|
||||
print("⚠️缺少redis依赖,请运行pip3 install redis")
|
||||
sys.exit()
|
||||
|
||||
def getToken(ck, r=None):
|
||||
host = f'{activityUrl.split("com/")[0]}com'
|
||||
try:
|
||||
# redis缓存Token 活动域名+pt_pin
|
||||
pt_pin = unquote_plus(re.compile(r'pt_pin=(.*?);').findall(ck)[0])
|
||||
except:
|
||||
# redis缓存Token 活动域名+ck前7位(获取pin失败)
|
||||
pt_pin = ck[:15]
|
||||
try:
|
||||
if r is not None:
|
||||
Token = r.get(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}')
|
||||
# print("Token过期时间", r.ttl(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}'))
|
||||
if Token is not None:
|
||||
print(f"♻️获取缓存Token")
|
||||
return Token
|
||||
else:
|
||||
# print("🈳去设置Token缓存")
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign_txt = sign({"url": f"{host}", "id": ""}, 'isvObfuscator')
|
||||
# print(sign_txt)
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
return
|
||||
Token_new = f.json()['token']
|
||||
# print(f"Token->: {Token_new}")
|
||||
if r.set(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}', Token_new, ex=1800):
|
||||
print("✅Token缓存成功")
|
||||
else:
|
||||
print("❌Token缓存失败")
|
||||
return Token_new
|
||||
else:
|
||||
s.headers = {
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'User-Agent': '',
|
||||
'Cookie': ck,
|
||||
'Host': 'api.m.jd.com',
|
||||
'Referer': '',
|
||||
'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9',
|
||||
'Accept': '*/*'
|
||||
}
|
||||
sign_txt = sign({"url": f"{host}", "id": ""}, 'isvObfuscator')
|
||||
# print(sign_txt)
|
||||
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
|
||||
if f.status_code != 200:
|
||||
print(f.status_code)
|
||||
return
|
||||
else:
|
||||
if "参数异常" in f.text:
|
||||
return
|
||||
Token = f.json()['token']
|
||||
print(f"✅获取实时Token")
|
||||
return Token
|
||||
except:
|
||||
return
|
||||
|
||||
def getJdTime():
|
||||
jdTime = int(round(time.time() * 1000))
|
||||
return jdTime
|
||||
|
||||
def randomString(e, flag=False):
|
||||
t = "0123456789abcdef"
|
||||
if flag: t = t.upper()
|
||||
n = [random.choice(t) for _ in range(e)]
|
||||
return ''.join(n)
|
||||
|
||||
def refresh_cookies(res):
|
||||
if res.cookies:
|
||||
cookies = res.cookies.get_dict()
|
||||
set_cookie = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
global activityCookie
|
||||
activityCookieMid = [i for i in activityCookie.split(';') if i != '']
|
||||
for i in activityCookieMid:
|
||||
for x in set_cookie:
|
||||
if i.split('=')[0] == x.split('=')[0]:
|
||||
if i.split('=')[1] != x.split('=')[1]:
|
||||
activityCookieMid.remove(i)
|
||||
activityCookie = ''.join(sorted([(set_cookie + ";") for set_cookie in list(set(activityCookieMid + set_cookie))]))
|
||||
|
||||
def getActivity():
|
||||
url = f"https://lzkj-isv.isvjcloud.com/wxShopGift/activity?activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'User-Agent': ua,
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Connection': 'keep-alive'
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
if response.status_code == 200:
|
||||
if response.cookies:
|
||||
cookies = response.cookies.get_dict()
|
||||
set_cookies = [(set_cookie + "=" + cookies[set_cookie]) for set_cookie in cookies]
|
||||
set_cookie = ''.join(sorted([(set_cookie + ";") for set_cookie in set_cookies]))
|
||||
return set_cookie
|
||||
else:
|
||||
print(response.status_code)
|
||||
print("⚠️疑似ip黑了")
|
||||
sys.exit()
|
||||
|
||||
def getSystemConfigForNew():
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxCommonInfo/getSystemConfigForNew"
|
||||
payload = f'activityId={activityId}&activityType=99'
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def getSimpleActInfoVo():
|
||||
url = "https://lzkj-isv.isvjcloud.com/customer/getSimpleActInfoVo"
|
||||
payload = f"activityId={activityId}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']
|
||||
|
||||
def getMyPing(venderId):
|
||||
url = "https://lzkj-isv.isvjcloud.com/customer/getMyPing"
|
||||
payload = f"userId={venderId}&token={token}&fromType=APP_shopGift"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
return res['data']['nickname'], res['data']['secretPin']
|
||||
else:
|
||||
print(f"⚠️{res['errorMessage']}")
|
||||
|
||||
def accessLogWithAD(venderId, pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/common/accessLogWithAD"
|
||||
payload = f"venderId={venderId}&code=24&pin={quote_plus(pin)}&activityId={activityId}&pageUrl={quote_plus(activityUrl)}&subType=app&adSource="
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
|
||||
def activityContent(pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxShopGift/activityContent"
|
||||
payload = f"activityId={activityId}&buyerPin={quote_plus(pin)}"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};{activityCookie}'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
refresh_cookies(response)
|
||||
res = response.json()
|
||||
act_label = True
|
||||
reward = ''
|
||||
if res['result']:
|
||||
endTime = res['data']['endTime']
|
||||
list = res['data']['list']
|
||||
if getJdTime() > endTime:
|
||||
print("⛈活动已结束,下次早点来~")
|
||||
sys.exit()
|
||||
if len(list) == 0:
|
||||
print("礼品已领完")
|
||||
act_label = False
|
||||
return act_label
|
||||
for r in list:
|
||||
reward += str(r['takeNum']) + r['type'] + ''
|
||||
if len(reward) > 0:
|
||||
reward = reward.replace('jd', '京豆').replace('jf', '积分').replace('dq', '东券')
|
||||
else:
|
||||
print(f"⛈{res['errorMessage']}")
|
||||
sys.exit()
|
||||
return reward, act_label
|
||||
|
||||
def draw(pin, nickname, reward):
|
||||
url = "https://lzkj-isv.isvjcloud.com/wxShopGift/draw"
|
||||
payload = f"activityId={activityId}&buyerPin={quote_plus(pin)}&hasFollow=false&accessType=app"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': f'IsvToken={token};{activityCookie}'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
res = response.json()
|
||||
if res['result']:
|
||||
print(f"🎉🎉🎉{nickname} 成功领取 {reward}")
|
||||
else:
|
||||
print(f"⛈⛈⛈{nickname} {res['errorMessage']}")
|
||||
|
||||
def attendLog(venderId, pin):
|
||||
url = "https://lzkj-isv.isvjcloud.com/common/attendLog"
|
||||
payload = f"venderId={venderId}&activityType=24&activityId={activityId}&pin={quote_plus(pin)}&clientType=app"
|
||||
headers = {
|
||||
'Host': 'lzkj-isv.isvjcloud.com',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://lzkj-isv.isvjcloud.com',
|
||||
'User-Agent': ua,
|
||||
'Connection': 'keep-alive',
|
||||
'Referer': activityUrl,
|
||||
'Cookie': activityCookie
|
||||
}
|
||||
requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = redis_conn()
|
||||
try:
|
||||
cks = getCk
|
||||
if not cks:
|
||||
sys.exit()
|
||||
except:
|
||||
print("未获取到有效COOKIE,退出程序!")
|
||||
sys.exit()
|
||||
num = 0
|
||||
for cookie in cks[:]:
|
||||
num += 1
|
||||
if num % 9 == 0:
|
||||
print("⏰等待8s,休息一下")
|
||||
time.sleep(8)
|
||||
global ua, activityCookie, token
|
||||
ua = userAgent()
|
||||
try:
|
||||
pt_pin = re.compile(r'pt_pin=(.*?);').findall(cookie)[0]
|
||||
pt_pin = unquote_plus(pt_pin)
|
||||
except IndexError:
|
||||
pt_pin = f'用户{num}'
|
||||
print(f'\n******开始【京东账号{num}】{pt_pin} *********\n')
|
||||
print(datetime.now())
|
||||
token = getToken(cookie, r)
|
||||
if token is None:
|
||||
print(f"⚠️获取Token失败!⏰等待2s")
|
||||
time.sleep(2)
|
||||
continue
|
||||
time.sleep(0.5)
|
||||
activityCookie = getActivity()
|
||||
time.sleep(0.5)
|
||||
getSystemConfigForNew()
|
||||
time.sleep(0.3)
|
||||
getSimAct = getSimpleActInfoVo()
|
||||
venderId = getSimAct['venderId']
|
||||
time.sleep(0.2)
|
||||
getPin = getMyPing(venderId)
|
||||
if getPin is not None:
|
||||
nickname = getPin[0]
|
||||
secretPin = getPin[1]
|
||||
time.sleep(0.3)
|
||||
accessLogWithAD(venderId, secretPin)
|
||||
time.sleep(0.5)
|
||||
actCon = activityContent(secretPin)
|
||||
if not actCon:
|
||||
continue
|
||||
if not actCon[1]:
|
||||
continue
|
||||
reward = actCon[0]
|
||||
time.sleep(0.8)
|
||||
draw(secretPin, nickname, reward)
|
||||
|
||||
time.sleep(5)
|
@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Time : 2022/7/6 23:00
|
||||
# @Author : HarbourJ
|
||||
# @TG : https://t.me/HarbourToulu
|
||||
# @File : jdCookie.py
|
||||
|
||||
import os
|
||||
import time
|
||||
from functools import partial
|
||||
print = partial(print, flush=True)
|
||||
|
||||
|
||||
def get_cookies():
|
||||
CookieJDs = []
|
||||
if os.environ.get("JD_COOKIE"):
|
||||
print("已获取并使用Env环境 Cookie")
|
||||
if '&' in os.environ["JD_COOKIE"]:
|
||||
CookieJDs = os.environ["JD_COOKIE"].split('&')
|
||||
elif '\n' in os.environ["JD_COOKIE"]:
|
||||
CookieJDs = os.environ["JD_COOKIE"].split('\n')
|
||||
else:
|
||||
CookieJDs = [os.environ["JD_COOKIE"]]
|
||||
# return CookieJDs
|
||||
else:
|
||||
if os.path.exists("JD_COOKIE.txt"):
|
||||
with open("JD_COOKIE.txt", 'r') as f:
|
||||
JD_COOKIEs = f.read().strip()
|
||||
if JD_COOKIEs:
|
||||
if '&' in JD_COOKIEs:
|
||||
CookieJDs = JD_COOKIEs.split('&')
|
||||
elif '\n' in JD_COOKIEs:
|
||||
CookieJDs = JD_COOKIEs.split('\n')
|
||||
else:
|
||||
CookieJDs = [JD_COOKIEs]
|
||||
CookieJDs = sorted(set(CookieJDs), key=CookieJDs.index)
|
||||
# return CookieJDs
|
||||
else:
|
||||
print("未获取到正确✅格式的京东账号Cookie")
|
||||
return
|
||||
|
||||
print(f"====================共{len(CookieJDs)}个京东账号Cookie=========\n")
|
||||
print(f"==================脚本执行- 北京时间(UTC+8):{time.strftime('%Y/%m/%d %H:%M:%S', time.localtime())}=====================\n")
|
||||
return CookieJDs
|
||||
|
||||
# if __name__ == "__main__":
|
||||
# get_cookies()
|
||||
# print(os.environ.get("JD_COOKIE"))
|
Loading…
Reference in New Issue
Block a user