This commit is contained in:
Faker
2022-08-31 11:14:37 +08:00
parent 1b920f5db9
commit 4ae2496ad8
13 changed files with 2624 additions and 10000 deletions

226
jd_check_dependent.py Normal file
View File

@@ -0,0 +1,226 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
File: jd_check_dependent.py(Harbour库依赖一键检测安装(不可禁用)每小时检测一次)
Author: HarbourJ
Date: 2022/8/12 20:37
TG: https://t.me/HarbourToulu
TgChat: https://t.me/HarbourSailing
cron: 0 0 */1 * * *
new Env('HarbourJ库依赖一键检测安装(不可禁用)');
Description:1.HarbourToulu库jd_sign本地算法依赖一键检测安装脚本;
2.自动识别机器系统/架构,拉取最新依赖文件;
3.本地sign算法已编译支持Windows(amd64)、Linux(amd64/arm64/arm)、Macos(x86_64)系统/架构;
4.默认支持python3版本为3.8-3.9,过高或过低可能会报错;
5.若本一键配置脚本无法安装所需jd_sign依赖文件,请前往https://github.com/HarbourJ/HarbourToulu/releases自行下载系统对应的jd_sign依赖压缩文件,解压并放置/scripts/HarbourJ_HarbourToulu_main文件夹内即可。
"""
import sys
import requests, os, platform
from functools import partial
print = partial(print, flush=True)
def updateDependent():
"""
更新依赖的主函数
"""
system = platform.system().lower()
if system == "windows":
print("识别本机设备为Windows amd64")
rtu = repoTreeUpdate()
if rtu == 9:
sys.exit()
if rtu:
removeOldSign()
if download("jd_sign-win-amd64.zip"):
import zipfile
f = zipfile.ZipFile("jd_sign-win-amd64.zip", 'r')
for file in f.namelist():
f.extract(file, os.getcwd())
f.close()
return True
elif system == "darwin":
print("识别本机设备为MacOS x86_64")
rtu = repoTreeUpdate()
if rtu == 9:
sys.exit()
if rtu:
removeOldSign()
if download("jd_sign-darwin-x86_64.tar.gz"):
os.system('tar xvf jd_sign-darwin-x86_64.tar.gz')
os.system('rm -rf jd_sign-darwin-x86_64.tar.gz')
return True
else:
print("识别本机设备为Linux")
rtu = repoTreeUpdate()
if rtu == 9:
sys.exit()
if rtu:
removeOldSign()
framework = os.uname().machine
if framework == "x86_64":
if download("jd_sign-linux-amd64.tar.gz"):
os.system('tar xvf jd_sign-linux-amd64.tar.gz')
os.system('rm -rf jd_sign-linux-amd64.tar.gz')
return True
elif framework == "aarch64" or framework == "arm64":
check_ld_libc()
if download("jd_sign-linux-arm64.tar.gz"):
os.system('tar xvf jd_sign-linux-arm64.tar.gz')
os.system('rm -rf jd_sign-linux-arm64.tar.gz')
return True
elif framework == "armv7l":
check_ld_libc()
if download("jd_sign-linux-arm.tar.gz"):
os.system('tar xvf jd_sign-linux-arm.tar.gz')
os.system('rm -rf jd_sign-linux-arm.tar.gz')
return True
else:
if download("jd_sign-linux-amd64.tar.gz"):
os.system('tar xvf jd_sign-linux-amd64.tar.gz')
os.system('rm -rf jd_sign-linux-amd64.tar.gz')
return True
def check_ld_libc():
"""
检测是否存在ld-linux-aarch64.so.1、libc.musl-aarch64.so.1动态依赖文件
"""
if "ld-linux-aarch64.so.1" in (os.listdir('/lib')):
print("已存在arm64-ld依赖")
pass
else:
if download("ld-linux-aarch64.tar.gz"):
os.system('tar xvf ld-linux-aarch64.tar.gz')
os.system('cp ld-linux-aarch64.so.1 /lib')
if "ld-linux-aarch64.so.1" in (os.listdir('/lib')):
print("arm64-ld依赖安装完成~")
os.system('rm -rf ld-linux-aarch64.tar.gz')
os.system('rm -rf ld-linux-aarch64.so.1')
else:
print("arm64-ld依赖安装失败,请前往https://github.com/HarbourJ/HarbourToulu/blob/main/README.md,查看依赖安装教程")
if "libc.musl-aarch64.so.1" in (os.listdir('/lib')):
print("已存在arm64-libc依赖")
pass
else:
if download("libc.musl-aarch64.tar.gz"):
os.system('tar xvf libc.musl-aarch64.tar.gz')
os.system('cp libc.musl-aarch64.so.1 /lib')
if "libc.musl-aarch64.so.1" in (os.listdir('/lib')):
print("arm64-libc依赖安装完成~")
os.system('rm -rf libc.musl-aarch64.tar.gz')
os.system('rm -rf libc.musl-aarch64.so.1')
else:
print("arm64-libc依赖安装失败,请前往https://github.com/HarbourJ/HarbourToulu/blob/main/README.md,查看依赖安装教程")
def download(systemFile):
raw_url = f"https://ghproxy.com/https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/utils/{systemFile}"
try:
fileList = os.listdir()
if systemFile in fileList:
os.remove(systemFile)
except:
print(f"删除{fileList}失败")
try:
try:
import wget
except ImportError as e:
print(e)
if "No module" in str(e):
os.system("pip install wget")
import wget
wget.download(raw_url)
print(f"{systemFile}下载成功")
return True
except Exception as e:
print(e)
print(f"{systemFile}下载失败")
return False
def removeOldSign():
fileList = os.listdir()
if "jd_sign.so" in fileList:
try:
os.remove("jd_sign.so")
print("成功删除历史jd_sign依赖文件")
except:
pass
elif "jd_sign_x86.so" in fileList:
try:
os.remove("jd_sign_x86.so")
print("成功删除历史jd_sign依赖文件")
except:
pass
elif "jd_sign_arm64.so" in fileList:
try:
os.remove("jd_sign_arm64.so")
print("成功删除历史jd_sign依赖文件")
except:
pass
def repoTreeUpdate():
"""
判断utils内的主要文件是否更新(sha值是否变化)
"""
GitAPI = 'https://api.github.com/repos/HarbourJ/HarbourToulu/git/trees/main'
try:
session = requests.session()
headers = {"Content-Type": "application/json"}
res = session.get(url=GitAPI, headers=headers, timeout=20)
if res.status_code == 200:
for x in res.json()["tree"]:
if "utils" == x["path"]:
new_sha = x["sha"]
print(new_sha)
# 获取上一次检查所记录的sha值
try:
with open('repoUpdate.log', "r") as f0:
last_sha = f0.read()
except Exception as e:
# print(e)
# 以log格式写入文件
with open("repoUpdate.log", "w") as f1:
f1.write('')
with open("repoUpdate.log", "w") as f2:
f2.write(new_sha)
if new_sha != last_sha:
print("检测到依赖版本有更新,自动更新...")
print("*" * 30)
return True
else:
print("检测到依赖版本无更新")
try:
from jd_sign import remote_redis
result = remote_redis(export_name="Test01", db_index=15)
print(result)
print("依赖正常,退出程序")
return 9
except:
print("依赖不正常,自动修复中...")
print("*" * 30)
return True
else:
print(f'请求失败:{GitAPI}')
if "message" in res.json():
print(f'错误信息:{res.json()["message"]}')
return False
except:
print(f'请求URL失败{GitAPI}')
return False
def main():
updateDependent()
try:
from jd_sign import remote_redis
result = remote_redis(export_name="Test01", db_index=15)
print(result)
if result:
print("依赖安装/更新完成")
except:
print("依赖安装/更新失败,请前往https://github.com/HarbourJ/HarbourToulu/blob/main/README.md,查看依赖安装教程")
if __name__ == '__main__':
main()

569
jd_jinggengInvite.py Normal file
View File

@@ -0,0 +1,569 @@
#!/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&inviterNick=Ny0m1K1tVHIJvt0j4SQ9RbRPXMHHf%2BDrNmMVfT8S5hq3SjYMAACrbEHZQ40J5yPY
变量设置: export redis_url="redis_ip", export redis_pwd="xxx"(没有可写变量)
export jinggengInviteJoin="9e80809282a4bdc90182ab254c7e0a12&1000121005"(活动id&店铺id)
"""
import time
import requests
import sys
import re
import os
from bs4 import BeautifulSoup
from datetime import datetime
import json
import random
from urllib.parse import quote_plus, unquote_plus
import logging
logging.basicConfig(level=logging.INFO, format='%(message)s')
logger = logging.getLogger()
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
from jd_sign import *
try:
from jdCookie import get_cookies
getCk = get_cookies()
except:
logger.info("请先下载依赖脚本,\n下载链接: https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
sys.exit(3)
try:
if os.environ.get("redis_url"):
redis_url = os.environ["redis_url"] # redis ip
else:
redis_url = "172.17.0.1"
if os.environ.get("redis_pwd"):
redis_pwd = os.environ["redis_pwd"] # redis 密码
else:
redis_pwd = ""
except:
redis_url = "172.17.0.1"
redis_pwd = ""
try:
if os.environ.get("jinggengInviteJoin"):
jinggengInviteJoin = os.environ["jinggengInviteJoin"]
else:
jinggengInviteJoin = "9e8080e0828365a10182868854b40115&1000004385"
except:
jinggengInviteJoin = "9e80809282a4bdc90182ab254c7e0a12&1000121005"
inviterNicks = [
"Ny0m1K1tVHIJvt0j4SQ9RbRPXMHHf%2BDrNmMVfT8S5hq3SjYMAACrbEHZQ40J5yPY",
"pWGUWZJQ3actex0X2vQyLsjNhNaYFy2HteErE6izlhTf9nrGY7gBkCdGU4C6z%2FxD"
]
if "&" not in jinggengInviteJoin:
logger.info("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}"
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')
logger.info('✅redis连接成功')
return r
except:
logger.info("redis连接异常")
except:
logger.info("缺少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[:8]
try:
if r is not None:
Token = r.get(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}')
# logger.info("Token过期时间", r.ttl(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}'))
if Token is not None:
logger.info(f"获取缓存Token->: {Token}")
return Token
else:
logger.info("🈳去设置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"{activityUrl}", "id": ""}, 'isvObfuscator')
# logger.info(sign_txt)
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
if f.status_code != 200:
logger.info(f.status_code)
return
else:
if "参数异常" in f.text:
return
Token_new = f.json()['token']
logger.info(f"Token->: {Token_new}")
if r.set(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}', Token_new, ex=1800):
logger.info("✅Token缓存设置成功")
else:
logger.info("❌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')
# logger.info(sign_txt)
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
if f.status_code != 200:
logger.info(f.status_code)
return
else:
if "参数异常" in f.text:
return
Token = f.json()['token']
logger.info(f"Token->: {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:
logger.info(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'])
logger.info(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']
logger.info(f"奖品{b}: {equityName} 奖励: {denomination} 总数: {freezeQuantity}份 剩余: {availableQuantity}份 需要邀请: {leveNum}")
if availableQuantity > 0:
needInviteNums.append((leveNum, awardId, equityType))
if len(needInviteNums) == 0:
logger.info(f"⛈⛈⛈活动奖品全部发完啦!")
sys.exit()
return errorMsg, inviteSuccNums, needInviteNums
return errorMsg0
elif "活动已结束" in html_text:
logger.info("😭活动已结束,下次早点来~")
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:
logger.info(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:
body = {"venderId": user_id, "shopId": user_id, "bindByVerifyCodeFlag": 1,"registerExtend": {},"writeChildFlag":0, "channel": 401}
url = f'https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={json.dumps(body)}&client=H5&clientVersion=9.2.0&uuid=88888&h5st=20220614102046318%3B7327310984571307%3Bef79a%3Btk02wa31b1c7718neoZNHBp75rw4pE%2Fw7fXko2SdFCd1vIeWy005pEHdm0lw2CimWpaw3qc9il8r9xVLHp%2Bhzmo%2B4swg%3Bdd9526fc08234276b392435c8623f4a737e07d4503fab90bf2cd98d2a3a778ac%3B3.0%3B1655173246318'
headers = {
'Host': 'api.m.jd.com',
'Cookie': cookie,
'Accept-Encoding': 'gzip, deflate, br',
'Connection': 'keep-alive',
'Accept': '*/*',
'User-Agent': ua,
'Referer': f'https://shopmember.m.jd.com/shopcard/?venderId={user_id}&channel=401&returnUrl={quote_plus(activityUrl + "&isOpenCard=1")}'
}
response = requests.get(url=url, headers=headers, timeout=30).text
res = json.loads(response)
if res['success']:
open_result = res['message']
if "火爆" in open_result:
logger.info(f"\t⛈⛈⛈{open_result}")
else:
logger.info(f"\t🎉🎉🎉{open_result}")
return res['message']
except Exception as e:
logger.info(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']
logger.info(f"\t🎉🎉成功领取{awardDenomination}{awardType}")
else:
logger.info(f"\t🎉🎉{res['msg']}")
if __name__ == '__main__':
r = redis_conn()
try:
cks = getCk
if not cks:
sys.exit()
except:
logger.info("未获取到有效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:
logger.info("⏰等待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}'
logger.info(f'\n******开始【京东账号{num}{pt_pin} *********\n')
logger.info(datetime.now())
token = ''
activityCookie = ''
activityCookie = getActivity(num, 0, inviterCode, 0)
try:
token = getToken(cookie, r)
if token is None:
if num == 1:
logger.info(f"车头获取Token失败,退出本程序!")
# sys.exit()
os._exit()
logger.info(f"获取Token失败⏰等待3s")
time.sleep(3)
continue
except:
logger.info(f"获取Token失败⏰等待3s")
time.sleep(3)
continue
time.sleep(1.5)
setMixNick0 = setMixNick(token)
if setMixNick0 is None:
if num == 1:
logger.info(f"⚠️车头获取邀请码失败,退出本程序!")
sys.exit()
else:
continue
else:
logger.info(f"邀请码->: {setMixNick0}")
time.sleep(1)
logger.info(f"准备助力-->: {inviterCode}")
inviteSuccNum = getActivity(num, 0, inviterCode, 1)
if num == 1:
errorMsg0 = inviteSuccNum[0]
if "跳开卡页面" not in errorMsg0:
logger.info("无法助力自己")
inviteSuccNums0 = inviteSuccNum[1]
needInviteNums = inviteSuccNum[2]
inviteSuccNums = len(eval(inviteSuccNums0))
logger.info(f"🛳已经邀请{inviteSuccNums}")
for i, needNum0 in enumerate(needInviteNums):
needNum = needNum0[0]
awardId = needNum0[1]
if inviteSuccNums >= needNum:
logger.info(f"🎉恭喜已完成第{i + 1}档邀请,快去领奖吧!")
time.sleep(1)
recordActPvUvdata(token)
checkTokenInSession(token)
time.sleep(1)
if equityType == "JD_GOODS":
logger.info(f"\t🎉🎉成功获得实物奖励,请尽快前往领取:{activityUrl}")
else:
receiveInviteJoinAward(token, awardId)
rewardIndex += 1
time.sleep(3)
if i + 1 == len(needInviteNums):
logger.info("🎉🎉🎉奖励全部领取完毕~")
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
# logger.info("num != 1", errorMsg1)
if "跳开卡页面" not in errorMsg1:
if "已成功邀请您加入本店会员" in errorMsg1:
logger.info("⛈已经是会员了,无法完成助力")
else:
logger.info(f"🛳{errorMsg1}")
time.sleep(1)
continue
time.sleep(1.5)
recordActPvUvdata(token)
checkTokenInSession(token)
time.sleep(1)
shopmember(cookie)
logger.info("现在去开卡")
open_result = bindWithVender(cookie)
if open_result is not None:
if "火爆" in open_result:
time.sleep(1.5)
logger.info("\t尝试重新入会 第1次")
open_result = bindWithVender(cookie)
if "火爆" in open_result:
time.sleep(1.5)
logger.info("\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)
# logger.info(errorMsg2, '============================')
if num == 1 and "开卡失败" in errorMsg2:
logger.info(f"⚠️车头疑似火爆号,退出本程序!")
sys.exit()
if "已成功邀请您加入本店会员" in errorMsg2:
inviteSuccNums += 1
logger.info(f"🛳已经邀请{inviteSuccNums}")
for i, needNum1 in enumerate(needInviteNums):
# logger.info(i, needNum1)
needNum = needNum1[0]
awardId = needNum1[1]
equityType = needNum1[2]
if inviteSuccNums >= needNum:
if rewardIndex >= i + 1:
time.sleep(1)
continue
logger.info(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":
logger.info(f"\t🎉🎉成功获得实物奖励,请尽快前往领取:{activityUrl}")
else:
receiveInviteJoinAward(token, awardId)
rewardIndex += 1
time.sleep(3)
if i + 1 == len(needInviteNums):
logger.info("🎉🎉🎉奖励全部领取完毕~")
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)

687
jd_joinCommon_opencard.py Normal file
View File

@@ -0,0 +1,687 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
File: jd_joinCommon_opencard.py(通用开卡-customized系列)
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
"""
import time
import requests
import sys
import re
import os
from datetime import datetime
import json
import random
from urllib.parse import quote_plus, unquote_plus
from functools import partial
print = partial(print, flush=True)
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
from jd_sign import *
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_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 ""
inviterUuids = [
"4d06aea11bd64802b4d615cf3977001d",
"479fbbaa47a8494a86ecefaacb6558cc",
"7eb63ebcab3e4503bf3d2b1ee3e0afa5",
]
inviterUuid = random.choice(inviterUuids)
if not jd_joinCommonId:
print("⚠️未发现有效活动变量,退出程序!")
sys.exit()
if jd_joinCommonId and "&" 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}"
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:
# 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[:8]
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->: {Token}")
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->: {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': '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={quote_plus(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)}"
body = {"venderId": venderId, "bindByVerifyCodeFlag": 1,"registerExtend": {},"writeChildFlag":0, "channel": 401}
url = f'https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={json.dumps(body)}&client=H5&clientVersion=9.2.0&uuid=88888&h5st=20220614102046318%3B7327310984571307%3Bef79a%3Btk02wa31b1c7718neoZNHBp75rw4pE%2Fw7fXko2SdFCd1vIeWy005pEHdm0lw2CimWpaw3qc9il8r9xVLHp%2Bhzmo%2B4swg%3Bdd9526fc08234276b392435c8623f4a737e07d4503fab90bf2cd98d2a3a778ac%3B3.0%3B1655173246318'
headers = {
'Host': 'api.m.jd.com',
'Cookie': cookie,
'Accept-Encoding': 'gzip, deflate, br',
'Connection': 'keep-alive',
'Accept': '*/*',
'User-Agent': ua,
'Referer': shopcard_url
}
response = requests.get(url=url, headers=headers, timeout=30).text
res = json.loads(response)
if res['success']:
return res['message']
except Exception as e:
print(e)
def getShopOpenCardInfo(cookie, venderId):
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)}"
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 shareUuid, inviteSuccNum, activityUrl, firstCk
inviteSuccNum = 0
shareUuid = inviterUuid
activityUrl = activity_url
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 = 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)
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 == 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:
time.sleep(1.5)
print("\t尝试重新入会 第1次")
open_result = bindWithVender(cookie, venderId)
if "火爆" in open_result:
time.sleep(1.5)
print("\t尝试重新入会 第2次")
open_result = bindWithVender(cookie, venderId)
if "火爆" in open_result:
print(f"\t⛈⛈{venderCardName} {open_result}")
assStat = False
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("🎉🎉🎉助力成功~")
inviteSuccNum += 1
print(f"本次车头已邀请{inviteSuccNum}")
if num == 1:
print(f"后面账号全部助力 {actorUuid}")
if num == 1:
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)

746
jd_mpdz8_0801.py Normal file
View File

@@ -0,0 +1,746 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
File: jd_mpdz8_0801.py(全民酿造 摘要酱香飘万家)
Author: HarbourJ
Date: 2022/8/1 23:37
TG: https://t.me/HarbourToulu
cron: 1 0 0,18 * 8 *
new Env('8.1-8.31 全民酿造 摘要酱香飘万家');
活动入口19全民酿造 摘要酱香飘万家,【⤴️ℹ️\/ 🆖レ栋】¥O53oq1PvEKlC¥
"""
import time
import requests
import sys
import re
from base64 import b64encode, b64decode
from datetime import datetime
import json
import random
from urllib.parse import quote, unquote
from urllib.parse import quote_plus, unquote_plus
import logging
logging.basicConfig(level=logging.INFO, format='%(message)s')
logger = logging.getLogger()
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
import os
from jd_sign import *
try:
from jdCookie import get_cookies
getCk = get_cookies()
except:
logger.info("请先下载依赖脚本,\n下载链接https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py")
sys.exit(3)
try:
if os.environ.get("redis_url"):
redis_url = os.environ["redis_url"] # redis ip
else:
redis_url = "172.17.0.1"
if os.environ.get("redis_pwd"):
redis_pwd = os.environ["redis_pwd"] # redis 密码
else:
redis_pwd = ""
except:
redis_url = "172.17.0.1"
redis_pwd = ""
activity_urls = ["https://mpdz8-dz.isvjcloud.com/jdbeverage/pages/zhaiyaohuodong/zhaiyaohuodong?bizExtString=c2hhcmVOaWNrOk55MG0xSzF0VkhJSnZ0MGo0U1E5UmJSUFhNSEhmJTJCRHJObU1WZlQ4UzVocTNTallNQUFDcmJFSFpRNDBKNXlQWSZoZWFkUGljVXJsOmh0dHAlM0ElMkYlMkZzdG9yYWdlLjM2MGJ1eWltZy5jb20lMkZpLmltYWdlVXBsb2FkJTJGMzEzNTM1MzIzMDMxMzYzODM2Mzg1ZjZkMzEzNDMwMzczNjM4MzMzODMyMzkzNTM2MzRfbWlkLmpwZyZuaWNrTmFtZTolRTUlQkYlODMlRTYlOTglOUYxOTk2", "https://mpdz8-dz.isvjcloud.com/jdbeverage/pages/zhaiyaohuodong/zhaiyaohuodong?bizExtString=c2hhcmVOaWNrOnBXR1VXWkpRM2FjdGV4MFgydlF5THNqTmhOYVlGeTJIdGVFckU2aXpsaFRmOW5yR1k3Z0JrQ2RHVTRDNnolMkZ4RCZoZWFkUGljVXJsOmh0dHAlM0ElMkYlMkZzdG9yYWdlLjM2MGJ1eWltZy5jb20lMkZpLmltYWdlVXBsb2FkJTJGNmE2NDVmNjc0MzUwNjc2YzQxNTg2ZDUyNTc0ZTY2MzEzNjM0MzYzNDM4MzYzOTM4MzMzNTMzMzZfbWlkLmpwZyZuaWNrTmFtZTpJcmVuZV9Db3Jwcw=="]
activity_url = random.choice(activity_urls)
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')
logger.info('✅redis连接成功')
return r
except:
logger.info("redis连接异常")
except:
logger.info("缺少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[:8]
if r is not None:
Token = r.get(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}')
# logger.info("Token过期时间", r.ttl(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}'))
if Token is not None:
logger.info(f"获取缓存Token->: {Token}")
return Token
else:
logger.info("🈳去设置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"{activityUrl}", "id": ""}, 'isvObfuscator')
# logger.info(sign_txt)
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
if f.status_code != 200:
logger.info(f.status_code)
return
else:
if "参数异常" in f.text:
logger.info("获取token失败")
return
Token_new = f.json()['token']
logger.info(f"Token->: {Token_new}")
if r.set(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}', Token_new, ex=1800):
logger.info("✅Token缓存设置成功")
else:
logger.info("❌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')
# logger.info(sign_txt)
f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30)
if f.status_code != 200:
logger.info(f.status_code)
return
else:
if "参数异常" in f.text:
logger.info("获取token失败")
return
Token = f.json()['token']
logger.info(f"Token->: {Token}")
return Token
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 buyerUrl(index=1, activity_url=None, buyerNick=None):
global activityUrl, shareNick, shareNick1
if index == 1:
activityUrl = activity_url
bizExtString = b64decode(activityUrl.split('bizExtString=')[1]).decode('utf-8')
bizExtString = unquote_plus(bizExtString)
shareNick = bizExtString.split('&')[0].split(':')[1]
else:
bizExtString = b64encode(bytes(f"shareNick:{quote_plus(buyerNick)}", encoding="utf-8")).decode()
activityUrl = f"{activityUrl.split('bizExtString=')[0]}bizExtString={bizExtString}"
shareNick = buyerNick
return activityUrl, shareNick
def getActivity(token):
url = activityUrl
headers = {
'Host': 'mpdz8-dz.isvjcloud.com',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Cookie': f'IsvToken={token};',
'User-Agent': ua,
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
'Accept-Encoding': 'gzip, deflate, br',
'Connection': 'keep-alive'
}
requests.request("GET", url, headers=headers)
def loadActivity(token):
url = "https://mpdz8-dz.isvjcloud.com/dm/front/jdMakeWine/activity/load?open_id=&mix_nick=&user_id=10299171"
payload = {"jsonRpc": "2.0", "params": {"admJson": {"buyerNick": "", "method": "/jdMakeWine/activity/load", "jdToken": token, "userId": 10299171, "actId": "makeWine", "inviteNick": "BrhkV49OBlcgmCGIvW/S6Fs/ye9oluZX4nOTK56TeMXbR7I2OlzZch4hTs22oCUS"}, "commonParameter": {"sign": "b098fbe22e9bf12af0a00cc9e68771ce", "timestamp": getJdTime(), "userId": 10299171, "m": "POST"}}}
headers = {
'Host': 'mpdz8-dz.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/json; charset=utf-8',
'Origin': 'https://mpdz8-dz.isvjcloud.com',
'User-Agent': ua,
'Connection': 'keep-alive',
'Referer': activityUrl
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
# logger.info('loadActivity', response.text)
return json.loads(response.text)
def drawList(buyerNick):
url = f"https://mpdz8-dz.isvjcloud.com/dm/front/jdMakeWine/awards/drawList?open_id=&mix_nick={buyerNick}&user_id=10299171"
payload = {"jsonRpc": "2.0", "params": {"commonParameter": {"m": "POST", "sign": "8b68429aee3b9a3808e8c161c7f38426", "timestamp": getJdTime(), "userId": 10299171}, "admJson": {"actId": "makeWine", "dataType": "exchange", "method": "/jdMakeWine/awards/drawList", "userId": 10299171, "buyerNick": buyerNick}}}
headers = {
'Host': 'mpdz8-dz.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/json; charset=utf-8',
'Origin': 'https://mpdz8-dz.isvjcloud.com',
'User-Agent': ua,
'Connection': 'keep-alive',
'Referer': activityUrl
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
# logger.info(response.text)
return json.loads(response.text)
def completeState(buyerNick):
url = f"https://mpdz8-dz.isvjcloud.com/dm/front/jdMakeWine/mission/completeState?open_id=&mix_nick={buyerNick}&user_id=10299171"
payload = {"jsonRpc": "2.0", "params": {"commonParameter": {"m": "POST", "sign": "583178491affed3125ae8e1a37ff3c02", "timestamp": getJdTime(), "userId": 10299171}, "admJson": {"actId": "makeWine", "method": "/jdMakeWine/mission/completeState", "userId": 10299171, "buyerNick": buyerNick}}}
headers = {
'Host': 'mpdz8-dz.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/json; charset=utf-8',
'Origin': 'https://mpdz8-dz.isvjcloud.com',
'User-Agent': ua,
'Connection': 'keep-alive',
'Referer': activityUrl
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
return json.loads(response.text)
def shopList(buyerNick):
url = f"https://mpdz8-dz.isvjcloud.com/dm/front/jdMakeWine/shop/shopList?open_id=&mix_nick={buyerNick}&user_id=10299171"
payload = {"jsonRpc": "2.0", "params": {"commonParameter": {"m": "POST", "sign": "872926dfff101f37ae7d551698162da2", "timestamp": getJdTime(), "userId": 10299171}, "admJson": {"actId": "makeWine", "method": "/jdMakeWine/shop/shopList", "userId": 10299171, "buyerNick": buyerNick}}}
headers = {
'Host': 'mpdz8-dz.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/json; charset=utf-8',
'Origin': 'https://mpdz8-dz.isvjcloud.com',
'User-Agent': ua,
'Connection': 'keep-alive',
'Referer': activityUrl
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
open_shopList = json.loads(response.text)
# logger.info('open_shopList', open_shopList)
unopen_shopList = []
if open_shopList['success']:
open_shopList = open_shopList['data']['data']
for shop in open_shopList:
if not shop['open']:
unopen_shopList.append(shop)
else:
return
return unopen_shopList
def getUserInfo(buyerNick):
url = f"https://mpdz8-dz.isvjcloud.com/dm/front/jdMakeWine/makeWine/getUserInfo?open_id=&mix_nick={buyerNick}&user_id=10299171"
payload = {"jsonRpc": "2.0", "params": {"commonParameter": {"m": "POST", "sign": "c9e3cf6d45e3d29d097c1b8f61e1f2a3", "timestamp": getJdTime(), "userId": 10299171}, "admJson": {"actId": "makeWine", "method": "/jdMakeWine/makeWine/getUserInfo", "userId": 10299171, "buyerNick": buyerNick}}}
headers = {
'Host': 'mpdz8-dz.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/json; charset=utf-8',
'Origin': 'https://mpdz8-dz.isvjcloud.com',
'User-Agent': ua,
'Connection': 'keep-alive',
'Referer': activityUrl
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
getUserInfo = json.loads(response.text)
if getUserInfo['success']:
getUserInfo = getUserInfo['data']['data']
# logger.info(getUserInfo)
def temporary(buyerNick, type):
url = f"https://mpdz8-dz.isvjcloud.com/dm/front/jdMakeWine/report/temporary?open_id=&mix_nick={buyerNick}&user_id=10299171"
payload = {"jsonRpc": "2.0", "params": {"commonParameter": {"m": "POST", "sign": "3c2b15d3209dd92a94995226f19b1694", "timestamp": getJdTime(), "userId": 10299171}, "admJson": {"actId": "makeWine", "type": type, "method": "/jdMakeWine/report/temporary", "userId": 10299171, "buyerNick": buyerNick}}}
headers = {
'Host': 'mpdz8-dz.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/json; charset=utf-8',
'Origin': 'https://mpdz8-dz.isvjcloud.com',
'User-Agent': ua,
'Connection': 'keep-alive',
'Referer': activityUrl
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
temporary = json.loads(response.text)
if temporary['success']:
temporary['data']['msg']
def inviteRelation(buyerNick):
url = f"https://mpdz8-dz.isvjcloud.com/dm/front/jdMakeWine/customer/inviteRelation?open_id=&mix_nick={buyerNick}&user_id=10299171"
payload = {"jsonRpc": "2.0", "params": {"commonParameter": {"m": "POST", "sign": "583178491affed3125ae8e1a37ff3c02", "timestamp": getJdTime(), "userId": 10299171}, "admJson": {"actId": "makeWine", "missionType": "relationBind", "method": "/jdMakeWine/customer/inviteRelation", "userId": 10299171, "inviterNick": shareNick, "buyerNick": buyerNick}}}
headers = {
'Host': 'mpdz8-dz.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/json; charset=utf-8',
'Origin': 'https://mpdz8-dz.isvjcloud.com',
'User-Agent': ua,
'Connection': 'keep-alive',
'Referer': activityUrl
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
inviteRelation = json.loads(response.text)
# logger.info('inviteRelation', inviteRelation)
if inviteRelation['success']:
msg = inviteRelation['data']['msg']
if "关系绑定成功" in msg:
logger.info(f"🎉{msg}")
else:
logger.info(f"☃️{msg}")
else:
errorMessage = inviteRelation['errorMessage']
logger.info(errorMessage)
def completeMissionQa(buyerNick, missionType, problemId, answerIds):
url = f"https://mpdz8-dz.isvjcloud.com/dm/front/jdMakeWine/mission/completeMission?open_id=&mix_nick={buyerNick}&user_id=10299171"
payload = {"jsonRpc": "2.0", "params": {"commonParameter": {"m": "POST", "sign": "1b96d3a4e5f083eaf631ebbfe8dc4c0e", "timestamp": getJdTime(), "userId": 10299171}, "admJson": {"actId": "makeWine", "missionType": missionType, "method": "/jdMakeWine/mission/completeMission", "userId": 10299171, "problemId": problemId, "answerIds": [answerIds], "buyerNick": buyerNick}}}
headers = {
'Host': 'mpdz8-dz.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/json; charset=utf-8',
'Origin': 'https://mpdz8-dz.isvjcloud.com',
'User-Agent': ua,
'Connection': 'keep-alive',
'Referer': activityUrl
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
completeMission = json.loads(response.text)
# logger.info('completeMission', missionType, response.text)
if completeMission['success']:
remark = completeMission['data']['data']['remark']
if "错误" in remark:
logger.info(f"\t😭{remark[:5]}奖励一个💨")
else:
logger.info(f"\t🎉{remark[:5]}获得10酿造币~")
else:
errorMessage = completeMission['data']
logger.info(errorMessage)
def getDailyQA(buyerNick):
url = f"https://mpdz8-dz.isvjcloud.com/dm/front/jdMakeWine/mission/getDailyQA?open_id=&mix_nick={buyerNick}&user_id=10299171"
payload = {"jsonRpc": "2.0", "params": {"commonParameter": {"m": "POST", "sign": "28108d03b6563f4bdbb848f3b57dfef7", "timestamp": getJdTime(), "userId": 10299171}, "admJson": {"actId": "makeWine", "method": "/jdMakeWine/shop/getHotGoods", "userId": 10299171, "buyerNick": buyerNick}}}
headers = {
'Host': 'mpdz8-dz.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/json; charset=utf-8',
'Origin': 'https://mpdz8-dz.isvjcloud.com',
'User-Agent': ua,
'Connection': 'keep-alive',
'Referer': activityUrl
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
getHotGoods = json.loads(response.text)
# logger.info('getDailyQA', response.text)
if getHotGoods['success']:
return getHotGoods['data']['data']
def completeMission(buyerNick, missionType):
url = f"https://mpdz8-dz.isvjcloud.com/dm/front/jdMakeWine/mission/completeMission?open_id=&mix_nick={buyerNick}&user_id=10299171"
payload = {"jsonRpc": "2.0", "params": {"commonParameter": {"m": "POST", "sign": "1b96d3a4e5f083eaf631ebbfe8dc4c0e", "timestamp": getJdTime(), "userId": 10299171}, "admJson": {"actId": "makeWine", "missionType": missionType, "method": "/jdMakeWine/mission/completeMission", "userId": 10299171, "buyerNick": buyerNick}}}
headers = {
'Host': 'mpdz8-dz.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/json; charset=utf-8',
'Origin': 'https://mpdz8-dz.isvjcloud.com',
'User-Agent': ua,
'Connection': 'keep-alive',
'Referer': activityUrl
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
completeMission = json.loads(response.text)
# logger.info('completeMission', missionType, response.text)
if completeMission['success']:
try:
remark = completeMission['data']['data']['remark']
logger.info(f"\t🛳{remark}")
except:
remark = completeMission['errorMessage']
logger.info(f"\t🛳{remark}")
else:
errorMessage = completeMission['data']
logger.info(errorMessage)
def getHotGoods(buyerNick, missionType):
url = f"https://mpdz8-dz.isvjcloud.com/dm/front/jdMakeWine/shop/getHotGoods?open_id=&mix_nick={buyerNick}&user_id=10299171"
payload = {"jsonRpc": "2.0", "params": {"commonParameter": {"m": "POST", "sign": "9f8eb7e86b73fb82177c5190208c8fe6", "timestamp": getJdTime(), "userId": 10299171}, "admJson": {"actId": "makeWine", "missionType": missionType, "method": "/jdMakeWine/shop/getHotGoods", "userId": 10299171, "buyerNick": buyerNick}}}
headers = {
'Host': 'mpdz8-dz.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/json; charset=utf-8',
'Origin': 'https://mpdz8-dz.isvjcloud.com',
'User-Agent': ua,
'Connection': 'keep-alive',
'Referer': activityUrl
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
getHotGoods = json.loads(response.text)
# logger.info('getHotGoods', missionType, response.text)
if getHotGoods['success']:
return getHotGoods['data']['data']['numId']
def completeMissionView(buyerNick, missionType, goodsId):
url = f"https://mpdz8-dz.isvjcloud.com/dm/front/jdMakeWine/mission/completeMission?open_id=&mix_nick={buyerNick}&user_id=10299171"
payload = {"jsonRpc": "2.0", "params": {"commonParameter": {"m": "POST", "sign": "1b96d3a4e5f083eaf631ebbfe8dc4c0e", "timestamp": getJdTime(), "userId": 10299171}, "admJson": {"actId": "makeWine", "missionType": missionType, "method": "/jdMakeWine/mission/completeMission", "goodsId": goodsId, "userId": 10299171, "buyerNick": buyerNick}}}
headers = {
'Host': 'mpdz8-dz.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/json; charset=utf-8',
'Origin': 'https://mpdz8-dz.isvjcloud.com',
'User-Agent': ua,
'Connection': 'keep-alive',
'Referer': activityUrl
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
completeMission = json.loads(response.text)
# logger.info('completeMission', missionType, response.text)
if completeMission['success']:
remark = completeMission['data']['data']['remark']
logger.info(remark)
else:
errorMessage = completeMission['data']
logger.info(errorMessage)
def shopmember(venderId, cookie):
shopcard_url = quote_plus(f"{activityUrl}?actId=makeWine&joinShopId={venderId}")
url = f"https://shopmember.m.jd.com/shopcard/?venderId={venderId}&channel=401&returnUrl={shopcard_url}"
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://mpdz8-dz.isvjcloud.com/',
'Accept-Encoding': 'gzip, deflate, br'
}
requests.request("GET", url, headers=headers)
def getShopOpenCardInfo(body, venderId, cookie, ua):
shopcard_url0 = quote_plus(f"{activityUrl}?actId=makeWine&joinShopId={venderId}")
shopcard_url = f"https://shopmember.m.jd.com/shopcard/?venderId={venderId}&channel=401&returnUrl={shopcard_url0}"
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
return json.loads(response)
def bindWithVender(cookie, venderId, body):
try:
shopcard_url0 = quote_plus(f"{activityUrl}?actId=makeWine&joinShopId={venderId}")
shopcard_url = f"https://shopmember.m.jd.com/shopcard/?venderId={venderId}&channel=401&returnUrl={shopcard_url0}"
url = f'https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={json.dumps(body)}&client=H5&clientVersion=9.2.0&uuid=88888&h5st=20220614090341129%3B0284392757226553%3Bef79a%3Btk02wcbf51cf018njrSeb2PERKoZxKtLTPV0g0paq33tkJwK4bJurufnMpBuFkn4RVxkfBmwRhN8VRd%2BB2q%2BrzaXvMR7%3B3f2a1efdb5f2b79e17aa8836a38af77030ad35b4aab128c11e3edbaa034c1733%3B3.0%3B1655168621129'
header = {
'Host': 'api.m.jd.com',
'Cookie': cookie,
'Accept-Encoding': 'gzip, deflate, br',
'Connection': 'keep-alive',
'Accept': '*/*',
'User-Agent': ua,
'Referer': shopcard_url
}
response = requests.get(url=url, headers=header, timeout=30).text
return json.loads(response)
except Exception as e:
logger.info(e)
def completeMissionCard(buyerNick, venderId, missionType):
url = f"https://mpdz8-dz.isvjcloud.com/dm/front/jdMakeWine/mission/completeMission?open_id=&mix_nick={buyerNick}&user_id=10299171"
payload = {"jsonRpc": "2.0", "params": {"commonParameter": {"m": "POST", "sign": "1b96d3a4e5f083eaf631ebbfe8dc4c0e", "timestamp": getJdTime(), "userId": 10299171}, "admJson": {"actId": "makeWine", "missionType": missionType, "method": "/jdMakeWine/mission/completeMission", "shopId": venderId, "userId": 10299171, "buyerNick": buyerNick}}}
headers = {
'Host': 'mpdz8-dz.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/json; charset=utf-8',
'Origin': 'https://mpdz8-dz.isvjcloud.com',
'User-Agent': ua,
'Connection': 'keep-alive',
'Referer': activityUrl
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
completeMission = json.loads(response.text)
if completeMission['success']:
remark = completeMission['data']['data']['remark']
if "入会成功" in remark:
logger.info(f"\t🎉🎉{remark}")
else:
logger.info(f"⛈⛈{remark}")
else:
errorMessage = completeMission['data']
logger.info(errorMessage)
def checkOpenCard(buyerNick):
url = f"https://mpdz8-dz.isvjcloud.com/dm/front/jdMakeWine/customer/checkOpenCard?open_id=&mix_nick={buyerNick}&user_id=10299171"
payload = {"jsonRpc": "2.0", "params": {"commonParameter": {"m": "POST", "sign": "157934762ac10948578eec2b24d270f6", "timestamp": getJdTime(), "userId": 10299171}, "admJson": {"actId": "makeWine", "method": "/jdMakeWine/customer/checkOpenCard", "userId": 10299171, "buyerNick": buyerNick}}}
headers = {
'Host': 'mpdz8-dz.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/json; charset=utf-8',
'Origin': 'https://mpdz8-dz.isvjcloud.com',
'User-Agent': ua,
'Connection': 'keep-alive',
'Referer': activityUrl
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
checkOpenCard = json.loads(response.text)
# logger.info('checkOpenCard', checkOpenCard)
if checkOpenCard['success']:
msg = checkOpenCard['data']['msg']
logger.info(msg)
else:
errorMessage = checkOpenCard['data']
logger.info(errorMessage)
if __name__ == '__main__':
r = redis_conn()
try:
cks = getCk
if not cks:
sys.exit()
except:
logger.info("未获取到有效COOKIE,退出程序!")
sys.exit()
num = 0
global activityUrl, buyerNick, shareNick, headPicUrl, nickName
activityUrl = None
shareNick = None
buyerNick = None
headPicUrl = None
nickName = None
for ck in cks:
num += 1
try:
pt_pin = re.compile(r'pt_pin=(.*?);').findall(ck)[0]
pt_pin = unquote_plus(pt_pin)
except IndexError:
pt_pin = f'用户{num}'
logger.info(f'\n******开始【京东账号{num}{pt_pin} *********\n')
logger.info(datetime.now())
ua = userAgent()
if num == 1:
activityUrl = activity_url
if num <= 2:
buyerInfo = buyerUrl8(num, activityUrl, buyerNick, headPicUrl, nickName)
activityUrl = buyerInfo[0]
shareNick = buyerInfo[1]
try:
token = getToken(ck, r)
if token is None:
continue
except:
continue
time.sleep(1)
getActivity(token)
time.sleep(1)
LA = loadActivity(token)
if LA['success']:
buyerNick = LA['data']['data']['missionCustomer']['buyerNick']
headPicUrl = LA['data']['data']['missionCustomer']['headPicUrl']
nickName = LA['data']['data']['missionCustomer']['nickName']
logger.info(f"邀请码->: {buyerNick}")
time.sleep(1.5)
drawAward = drawList(buyerNick)
if drawAward['success']:
if num == 1:
drawAwardList = drawAward['data']['data']['drawAwardList']
numb = 0
for drawAward in drawAwardList:
numb += 1
logger.info(f"奖品{numb}: {drawAward['awardName']} 剩余{drawAward['remainNum']}份 兑换需{drawAward['needNum']}坛白酒")
time.sleep(1)
complete_data = completeState(buyerNick)
if complete_data['success']:
data = complete_data['data']['data']
time.sleep(1)
logger.info(f"准备助力->: {shareNick}")
temporary(buyerNick, "pv")
shopList0 = shopList(buyerNick)
time.sleep(1)
getUserInfo(buyerNick)
time.sleep(1)
# temporary(buyerNick, "pv")
inviteRelation(buyerNick)
temporary(buyerNick, "renwu")
time.sleep(1.5)
# 完成日常任务
# data[-1], data[-2] = data[-2], data[-1] # 调换开卡邀请顺序
data[-1], data[1] = data[1], data[-1]
data[-2], data[-1] = data[-1], data[-2]
data[2], data[0] = data[0], data[2]
for i in data[:-1]:
# logger.info(i)
if i['isComplete']:
logger.info(f"{i['missionName']} 已完成")
else:
logger.info(f"现在去做{i['missionName']}任务")
# 购买商品(跳过)
if i['type'] == 'payTrade':
logger.info("\t😆先v船长999")
time.sleep(0.5)
continue
# 浏览商品
elif i['type'] == 'viewTimes':
for index in range(6-i['hasGotNum']):
temporary(buyerNick, "liulanshangpin")
time.sleep(0.5)
goodsId = getHotGoods(buyerNick, "viewTimes")
logger.info(f"⏰浏览商品 {goodsId},等待15s")
time.sleep(15)
completeMissionView(buyerNick, "viewTimes", goodsId)
time.sleep(0.5)
# 开卡入会
elif i['type'] == 'openCard':
if shopList0 is not None:
# logger.info('shopList0', shopList0)
if len(shopList0) > 0:
logger.info("准备开卡")
for shop0 in shopList0:
shopTitle = shop0['shopTitle']
venderId = shop0['userId']
shopId = shop0['shopId']
temporary(buyerNick, "ruhui")
completeMissionCard(buyerNick, venderId, "openCard")
time.sleep(0.5)
shopmember(venderId, ck)
time.sleep(0.5)
# 检查入会状态
try:
result1 = getShopOpenCardInfo({"venderId": str(venderId), "channel": "401"}, venderId, ck, ua)
# logger.info(result1)
except:
continue
try:
if result1['result']['userInfo']['openCardStatus'] == 0:
ruhui = bindWithVender(ck, venderId, {"venderId": str(venderId), "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": 2592549, "channel": 401})
logger.info(f"\t{shopTitle} {ruhui['message']}")
if "火爆" in str(ruhui) or "失败" in str(ruhui):
logger.info("尝试重新入会 第1次")
time.sleep(2.5)
ruhui = bindWithVender(ck, venderId, {"venderId": str(venderId), "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": 2592549, "channel": 401})
logger.info(f"\t{shopTitle} {ruhui['message']}")
if "火爆" in str(ruhui) or "失败" in str(ruhui):
logger.info("尝试重新入会 第2次")
time.sleep(2.5)
ruhui = bindWithVender(ck, venderId, {"venderId": str(venderId),
"bindByVerifyCodeFlag": 1,
"registerExtend": {},
"writeChildFlag": 0,
"activityId": 2592549,
"channel": 401})
logger.info(f"\t{shopTitle} {ruhui['message']}")
# **********************
getActivity(token)
time.sleep(0.5)
loadActivity(token)
time.sleep(0.5)
drawList(buyerNick)
time.sleep(0.5)
completeState(buyerNick)
time.sleep(0.5)
temporary(buyerNick, "ruhui")
completeMissionCard(buyerNick, venderId, "openCard")
time.sleep(0.5)
getUserInfo(buyerNick)
temporary(buyerNick, "pv")
time.sleep(0.5)
shopList1 = shopList(buyerNick)
if len(shopList1) == 0:
logger.info("😆开卡任务已完成")
time.sleep(0.5)
except:
continue
else:
logger.info("\t已全部开卡")
# **********************
temporary(buyerNick, "yaoqing")
checkOpenCard(buyerNick)
# time.sleep(1)
# temporary(buyerNick, "renwu")
# inviteRelation(buyerNick)
time.sleep(1)
# 每日问答
elif i['type'] == 'dailyQa':
QA = getDailyQA(buyerNick)
problemId = QA['problem']['id']
answerId = QA['answers'][-1]['id']
time.sleep(0.5)
temporary(buyerNick, "wenda")
completeMissionQa(buyerNick, "dailyQa", problemId, answerId)
time.sleep(1.5)
else:
# 签到、关注、加购
temporary(buyerNick, "renwu")
completeMission(buyerNick, i['type'])
time.sleep(1.5)

396
jd_wxShopGift.py Normal file
View File

@@ -0,0 +1,396 @@
#!/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('店铺特效关注有礼');
ActivityEntry: https://lzkj-isv.isvjcloud.com/wxShopGift/activity?activityId=971e85d5dfd445e1acfc63bafffb8ecc
"""
import time
import requests
import sys
import re
import os
from datetime import datetime
import json
import random
from urllib.parse import quote_plus, unquote_plus
from functools import partial
print = partial(print, flush=True)
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
from jd_sign import *
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_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=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:
# 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[:8]
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->: {Token}")
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->: {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)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
utils/jd_sign-win-amd64.zip Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff