mirror of
https://github.com/shufflewzc/faker2.git
synced 2025-04-23 10:58:44 +08:00
Update jd_yqhy.py
This commit is contained in:
parent
c8e70ab8ba
commit
7126abfcad
115
jd_yqhy.py
115
jd_yqhy.py
@ -1,28 +1,30 @@
|
|||||||
"""
|
"""
|
||||||
# 邀好友赢大礼 create by doubi 通用模板
|
# 邀好友赢大礼 create by doubi 通用模板
|
||||||
# https://prodev.m.jd.com/mall/active/dVF7gQUVKyUcuSsVhuya5d2XD4F/index.html?code=<活动id>&invitePin=<邀请用户名>
|
# 17:/椋东送福利,邀请好友,争排行榜排位,大礼送不停,(E1Y7RAtC4b) ,升级新版猄·=·Dσσōngαpρ
|
||||||
# 邀请用户名为助力 pin 且必须存在于ck中
|
# https://prodev.m.jd.com/mall/active/dVF7gQUVKyUcuSsVhuya5d2XD4F/index.html?code=16dde1860f1b4f1b9a93db6612abf0b9&invitePin=pin值
|
||||||
|
# 注意事项 pin 为助力pin 必须保证ck在里面
|
||||||
|
|
||||||
|
|
||||||
环境变量说明:
|
环境变量说明:
|
||||||
export yhyauthorCode="活动ID" // 必填
|
export yhypin="需要助力的pin值"
|
||||||
export yhyactivityId="活动类型ID" // 不指定则默认为"dVF7gQUVKyUcuSsVhuya5d2XD4F"
|
export yhyactivityId="活动类型ID"
|
||||||
export yhypin="需要助力的pin值" // 不指定则默认为头部账号1
|
export yhyauthorCode="活动ID"
|
||||||
|
|
||||||
new Env('邀请好友开卡有礼');
|
|
||||||
# const $ = new Env('邀请好友开卡有礼');
|
|
||||||
cron: 7 7 7 7 7
|
|
||||||
|
|
||||||
|
cron: 6 6 6 6 *
|
||||||
|
new Env('邀请赢大礼');
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json,requests,random,time,asyncio,re,os
|
import json
|
||||||
|
import requests,random,time,asyncio,re,os
|
||||||
from urllib.parse import quote_plus,unquote_plus
|
from urllib.parse import quote_plus,unquote_plus
|
||||||
from functools import partial
|
from functools import partial
|
||||||
print = partial(print, flush=True)
|
print = partial(print, flush=True)
|
||||||
|
|
||||||
activatyname = '邀请好友开卡有礼'
|
activatyname = '邀请赢大礼'
|
||||||
activityId = os.getenv('yhyactivityId', "dVF7gQUVKyUcuSsVhuya5d2XD4F") # 活动类型
|
activityId = os.environ["yhyactivityId"] # 活动类型
|
||||||
authorCode = os.environ["yhyauthorCode"] # 活动id
|
authorCode = os.environ["yhyauthorCode"] # 活动id
|
||||||
invitePin = activityUrl = ''
|
invitePin = os.environ["yhypin"] # pin 填写cookie后面的pin
|
||||||
|
activityUrl = f'https://prodev.m.jd.com/mall/active/{activityId}/index.html?code={authorCode}&invitePin={invitePin}'
|
||||||
|
|
||||||
# 随机ua
|
# 随机ua
|
||||||
def randomuserAgent():
|
def randomuserAgent():
|
||||||
@ -31,8 +33,7 @@ def randomuserAgent():
|
|||||||
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||||
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'z'], 40))
|
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'z'], 40))
|
||||||
addressid = ''.join(random.sample('1234567898647', 10))
|
addressid = ''.join(random.sample('1234567898647', 10))
|
||||||
iosVer = ''.join(random.sample(
|
iosVer = ''.join(random.sample(["15.1.1", "14.5.1", "14.4", "14.3", "14.2", "14.1", "14.0.1"], 1))
|
||||||
["15.1.1", "14.5.1", "14.4", "14.3", "14.2", "14.1", "14.0.1"], 1))
|
|
||||||
iosV = iosVer.replace('.', '_')
|
iosV = iosVer.replace('.', '_')
|
||||||
clientVersion = ''.join(random.sample(["10.3.0", "10.2.7", "10.2.4"], 1))
|
clientVersion = ''.join(random.sample(["10.3.0", "10.2.7", "10.2.4"], 1))
|
||||||
iPhone = ''.join(random.sample(["8", "9", "10", "11", "12", "13"], 1))
|
iPhone = ''.join(random.sample(["8", "9", "10", "11", "12", "13"], 1))
|
||||||
@ -49,7 +50,6 @@ def randomuserAgent():
|
|||||||
else:
|
else:
|
||||||
return UserAgent
|
return UserAgent
|
||||||
|
|
||||||
|
|
||||||
# 检测ck状态
|
# 检测ck状态
|
||||||
async def check(ua, ck):
|
async def check(ua, ck):
|
||||||
try:
|
try:
|
||||||
@ -75,13 +75,11 @@ async def check(ua, ck):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return {'code': 0, 'data': e}
|
return {'code': 0, 'data': e}
|
||||||
|
|
||||||
|
|
||||||
# 获取当前时间
|
# 获取当前时间
|
||||||
def get_time():
|
def get_time():
|
||||||
time_now = round(time.time()*1000)
|
time_now = round(time.time()*1000)
|
||||||
return time_now
|
return time_now
|
||||||
|
|
||||||
|
|
||||||
# 登录plogin
|
# 登录plogin
|
||||||
async def plogin(ua,cookie):
|
async def plogin(ua,cookie):
|
||||||
now = get_time()
|
now = get_time()
|
||||||
@ -99,9 +97,9 @@ async def plogin(ua, cookie):
|
|||||||
response = requests.get(url=url,headers=header,timeout=30).text
|
response = requests.get(url=url,headers=header,timeout=30).text
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
# 活动接口
|
# 活动接口
|
||||||
async def jdjoy(ua,cookie):
|
async def jdjoy(ua,cookie):
|
||||||
|
|
||||||
url = f'https://jdjoy.jd.com/member/bring/getActivityPage?code={authorCode}&invitePin={invitePin}&_t={get_time()}'
|
url = f'https://jdjoy.jd.com/member/bring/getActivityPage?code={authorCode}&invitePin={invitePin}&_t={get_time()}'
|
||||||
header = {
|
header = {
|
||||||
'Accept':'*/*',
|
'Accept':'*/*',
|
||||||
@ -118,7 +116,6 @@ async def jdjoy(ua, cookie):
|
|||||||
response = requests.get(url=url,headers=header).text
|
response = requests.get(url=url,headers=header).text
|
||||||
return json.loads(response)
|
return json.loads(response)
|
||||||
|
|
||||||
|
|
||||||
# go开卡
|
# go开卡
|
||||||
async def ruhui(ua,cookie):
|
async def ruhui(ua,cookie):
|
||||||
url = f'https://jdjoy.jd.com/member/bring/joinMember?code={authorCode}&invitePin={invitePin}'
|
url = f'https://jdjoy.jd.com/member/bring/joinMember?code={authorCode}&invitePin={invitePin}'
|
||||||
@ -138,7 +135,6 @@ async def ruhui(ua, cookie):
|
|||||||
response = requests.get(url=url,headers=header).text
|
response = requests.get(url=url,headers=header).text
|
||||||
return json.loads(response)
|
return json.loads(response)
|
||||||
|
|
||||||
|
|
||||||
# 检查开卡状态
|
# 检查开卡状态
|
||||||
async def check_ruhui(body,cookie,venderId,ua):
|
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'
|
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'
|
||||||
@ -155,7 +151,6 @@ async def check_ruhui(body, cookie, venderId, ua):
|
|||||||
response = requests.get(url=url,headers=headers,timeout=30000).text
|
response = requests.get(url=url,headers=headers,timeout=30000).text
|
||||||
return json.loads(response)
|
return json.loads(response)
|
||||||
|
|
||||||
|
|
||||||
# 领取奖励
|
# 领取奖励
|
||||||
async def getInviteReward(cookie,ua,number):
|
async def getInviteReward(cookie,ua,number):
|
||||||
url = f'https://jdjoy.jd.com/member/bring/getInviteReward?code={authorCode}&stage={number}'
|
url = f'https://jdjoy.jd.com/member/bring/getInviteReward?code={authorCode}&stage={number}'
|
||||||
@ -172,12 +167,7 @@ async def getInviteReward(cookie, ua, number):
|
|||||||
'User-Agent':ua
|
'User-Agent':ua
|
||||||
}
|
}
|
||||||
response = requests.get(url=url,headers=header).text
|
response = requests.get(url=url,headers=header).text
|
||||||
data = json.loads(response)
|
return json.loads(response)
|
||||||
if data['success'] == True:
|
|
||||||
return "🎉 领取成功"
|
|
||||||
else:
|
|
||||||
return data['errorMessage']
|
|
||||||
|
|
||||||
|
|
||||||
# 开启活动
|
# 开启活动
|
||||||
async def firstInvite(cookie,ua):
|
async def firstInvite(cookie,ua):
|
||||||
@ -192,10 +182,9 @@ async def firstInvite(cookie, ua):
|
|||||||
'User-Agent':ua
|
'User-Agent':ua
|
||||||
}
|
}
|
||||||
response = requests.get(url=url,headers=header).text
|
response = requests.get(url=url,headers=header).text
|
||||||
# print(response)
|
print(response)
|
||||||
return json.loads(response)
|
return json.loads(response)
|
||||||
|
|
||||||
|
|
||||||
async def get_ck(data):
|
async def get_ck(data):
|
||||||
cklist = []
|
cklist = []
|
||||||
if data['code']!=200:
|
if data['code']!=200:
|
||||||
@ -220,7 +209,6 @@ def checkpin(cks: list, pin):
|
|||||||
|
|
||||||
# 主程序
|
# 主程序
|
||||||
async def main():
|
async def main():
|
||||||
global invitePin, activityUrl
|
|
||||||
try:
|
try:
|
||||||
cks = os.environ["JD_COOKIE"].split("&")
|
cks = os.environ["JD_COOKIE"].split("&")
|
||||||
except:
|
except:
|
||||||
@ -231,15 +219,11 @@ async def main():
|
|||||||
needinviteNum = [] # 需要助力次数
|
needinviteNum = [] # 需要助力次数
|
||||||
needdel = []
|
needdel = []
|
||||||
need = []
|
need = []
|
||||||
r = re.compile(r'pt_pin=(.+?);')
|
|
||||||
invitePinCk1 = r.findall(cks[0])
|
|
||||||
invitePin = os.getenv('yhypin', invitePinCk1) # pin 填写cookie后面的pin
|
|
||||||
activityUrl = f'https://prodev.m.jd.com/mall/active/{activityId}/index.html?code={authorCode}&invitePin={invitePin}'
|
|
||||||
if inveteck:
|
if inveteck:
|
||||||
print(f'\n🔔{activatyname}\n', flush=True)
|
print(f'🔔{activatyname}', flush=True)
|
||||||
print(f'==================== 共{len(cks)}个京东账号Cookie ====================\n')
|
print(f'==================共{len(cks)}个京东账号Cookie==================')
|
||||||
print(f'=============== 脚本执行 - 北京时间(UTC+8) ' + time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())) + ' ===============\n')
|
print(f'==================脚本执行- 北京时间(UTC+8):{get_time()}=====================\n')
|
||||||
# print(f'您好!{invitePin},正在获取您的活动信息',)
|
print(f'您好!{invitePin},正在获取您的活动信息',)
|
||||||
ua = randomuserAgent() # 获取ua
|
ua = randomuserAgent() # 获取ua
|
||||||
result = await check(ua, inveteck) # 检测ck
|
result = await check(ua, inveteck) # 检测ck
|
||||||
if result['code'] == 200:
|
if result['code'] == 200:
|
||||||
@ -254,26 +238,19 @@ async def main():
|
|||||||
successCount = result['data']['successCount'] # 当前成功数
|
successCount = result['data']['successCount'] # 当前成功数
|
||||||
success += successCount
|
success += successCount
|
||||||
result_data = result['data']['rewards'] # 奖品数据
|
result_data = result['data']['rewards'] # 奖品数据
|
||||||
print(f'账号 {invitePin} ,开启{brandName}邀请好友开卡有礼活动\n')
|
print(f'您好!账号[{invitePin}],开启{brandName}邀请好友活动\n去开活动')
|
||||||
Judge_Beans_Mark = True
|
|
||||||
for i in result_data:
|
for i in result_data:
|
||||||
stage = i['stage']
|
stage = i['stage']
|
||||||
inviteNum = i['inviteNum'] # 单次需要拉新人数
|
inviteNum = i['inviteNum'] # 单次需要拉新人数
|
||||||
need.append(inviteNum)
|
need.append(inviteNum)
|
||||||
rewardName = i['rewardName'] # 奖品名
|
rewardName = i['rewardName'] # 奖品名
|
||||||
rewardNum = i['rewardStock'] # 奖品剩余数量
|
rewardNum = i['rewardStock']
|
||||||
if rewardNum !=0:
|
if rewardNum !=0:
|
||||||
needinviteNum.append(inviteNum)
|
needinviteNum.append(inviteNum)
|
||||||
needdel.append(inviteNum)
|
needdel.append(inviteNum)
|
||||||
if rewardNum == 0:
|
rewardslist.append(f'级别{stage}: 需助力{inviteNum}人,奖品: {rewardName},库存:{rewardNum}件\n')
|
||||||
rewardslist.append(f'等级{stage}: {rewardName},奖品已发完,需助力{inviteNum}人')
|
|
||||||
else:
|
|
||||||
rewardslist.append(f'等级{stage}: {rewardName},还剩{rewardNum}件库存,需助力{inviteNum}人')
|
|
||||||
|
|
||||||
if len(rewardslist)!=0:
|
if len(rewardslist)!=0:
|
||||||
print('活动奖品清单: \n' + str('\n'.join(rewardslist)) +
|
print('当前活动奖品如下: \n'+str('\n'.join(rewardslist))+f'\n当前已助力{successCount}次\n')
|
||||||
f'\n\n当前账号已邀请{successCount}人')
|
|
||||||
|
|
||||||
for nmubers in needdel:
|
for nmubers in needdel:
|
||||||
if success >= nmubers:
|
if success >= nmubers:
|
||||||
print("您当前助力已经满足了,可以去领奖励了")
|
print("您当前助力已经满足了,可以去领奖励了")
|
||||||
@ -284,9 +261,8 @@ async def main():
|
|||||||
await asyncio.sleep(10)
|
await asyncio.sleep(10)
|
||||||
needdel = needinviteNum
|
needdel = needinviteNum
|
||||||
if needinviteNum == []:
|
if needinviteNum == []:
|
||||||
print('奖励已经全部获取啦,退出程序\n')
|
print('奖励已经全部获取啦,退出程序')
|
||||||
return
|
return
|
||||||
num = 1
|
|
||||||
for n,ck in enumerate(cks,1):
|
for n,ck in enumerate(cks,1):
|
||||||
ua = randomuserAgent() # 获取ua
|
ua = randomuserAgent() # 获取ua
|
||||||
try:
|
try:
|
||||||
@ -294,45 +270,45 @@ async def main():
|
|||||||
pin = (unquote_plus(pin[1]))
|
pin = (unquote_plus(pin[1]))
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pin = f'用户{n}'
|
pin = f'用户{n}'
|
||||||
|
print(f'******开始【京东账号{n}】{pin} *********\n')
|
||||||
for n,nmubers in enumerate(needinviteNum,1):
|
for n,nmubers in enumerate(needinviteNum,1):
|
||||||
for nmubers in needdel:
|
for nmubers in needdel:
|
||||||
if success >= nmubers:
|
if success >= nmubers:
|
||||||
## print(nmubers)
|
print(nmubers)
|
||||||
print(f'已完成第{need.index(nmubers)+1}阶段的邀请任务,开始领取奖品~')
|
print("您当前助力已经满足了,可以去领奖励了")
|
||||||
|
print(f'\n这就去领取奖励{need.index(nmubers)+1}')
|
||||||
result = await getInviteReward(inveteck,ua,need.index(nmubers)+1)
|
result = await getInviteReward(inveteck,ua,need.index(nmubers)+1)
|
||||||
print(result)
|
print(result)
|
||||||
needinviteNum.remove(nmubers)
|
needinviteNum.remove(nmubers)
|
||||||
await asyncio.sleep(10)
|
await asyncio.sleep(10)
|
||||||
needdel = needinviteNum
|
needdel = needinviteNum
|
||||||
if needinviteNum == []:
|
if needinviteNum == []:
|
||||||
print('')
|
print('奖励已经全部获取啦,退出程序')
|
||||||
return
|
return
|
||||||
print(f'\n******开始【京东账号{num}】{pin} ******\n')
|
|
||||||
num+=1
|
|
||||||
await plogin(ua,ck) # 获取登录状态
|
await plogin(ua,ck) # 获取登录状态
|
||||||
result = await check(ua, ck) # 检测ck
|
result = await check(ua, ck) # 检测ck
|
||||||
if result['code'] == 200:
|
if result['code'] == 200:
|
||||||
result = await jdjoy(ua,ck) # 调用ck
|
result = await jdjoy(ua,ck) # 调用ck
|
||||||
if result['success']:
|
if result['success']:
|
||||||
# print(f'账户[{pin}]已开启{brandName}邀请好友活动\n')
|
print(f'账户[{pin}]已开启{brandName}邀请好友活动\n')
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(3)
|
||||||
# 检查入会状态
|
result= await check_ruhui({"venderId":str(venderId), "channel": "401" },ck,venderId,ua) # 检查入会状态
|
||||||
result = await check_ruhui({"venderId": str(venderId), "channel": "401"}, ck, venderId, ua)
|
|
||||||
try:
|
try:
|
||||||
if result['result']['userInfo']['openCardStatus']==0: # 0 未开卡
|
if result['result']['userInfo']['openCardStatus']==0: # 0 未开卡
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(2)
|
||||||
|
print(f'您还不是会员哦,这就去去助力{invitePin}\n')
|
||||||
result = await ruhui(ua,ck)
|
result = await ruhui(ua,ck)
|
||||||
if result['success']:
|
if result['success']:
|
||||||
success +=1
|
success +=1
|
||||||
print(f'助力成功! 当前已邀请{success}人')
|
print(f'助力成功! 当前成功助力{success}个\n')
|
||||||
if '交易失败' in str(result):
|
if '交易失败' in str(result):
|
||||||
success +=1
|
success +=1
|
||||||
print(f'助力成功! 当前已邀请{success}人')
|
print(f'助力成功! 当前成功助力{success}个\n')
|
||||||
else:
|
else:
|
||||||
print(result)
|
print(result)
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(2)
|
||||||
else:
|
else:
|
||||||
print('已经是会员了,无法助力~')
|
print('您已经是会员啦,不去请求了入会了\n')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
@ -340,10 +316,10 @@ async def main():
|
|||||||
result = await ruhui(ua,ck)
|
result = await ruhui(ua,ck)
|
||||||
if result['success']:
|
if result['success']:
|
||||||
success +=1
|
success +=1
|
||||||
print(f'助力成功! 当前已邀请{success}人')
|
print(f'助力成功! 当前成功助力{success}个\n')
|
||||||
if '交易失败' in result:
|
if '交易失败' in result:
|
||||||
success +=1
|
success +=1
|
||||||
print(f'助力成功! 当前已邀请{success}人')
|
print(f'助力成功! 当前成功助力{success}个\n')
|
||||||
else:
|
else:
|
||||||
print(result['errorMessage'])
|
print(result['errorMessage'])
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(2)
|
||||||
@ -359,11 +335,8 @@ async def main():
|
|||||||
return
|
return
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(result['data'] + '\n')
|
print(result['data'])
|
||||||
return
|
return
|
||||||
|
|
||||||
print(f'\n🔔{activatyname}, 结束!\n', flush=True)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(f'pin填写有误,请重试')
|
print(f'pin填写有误,请重试')
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user