mirror of
https://github.com/CHERWING/CHERWIN_SCRIPTS.git
synced 2024-11-22 09:04:11 +08:00
更新脚本
This commit is contained in:
parent
5a1deccaa2
commit
fc39ef5c83
577
BWCJ.py
577
BWCJ.py
@ -1,286 +1,293 @@
|
||||
# !/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
# -------------------------------
|
||||
# cron "30 1 * * *" script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('霸王茶姬小程序')
|
||||
|
||||
import os
|
||||
import requests
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# import CHERWIN_TOOLS
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
else:
|
||||
print("加载通知服务失败!")
|
||||
send_msg = ''
|
||||
one_msg=''
|
||||
def Log(cont=''):
|
||||
global send_msg,one_msg
|
||||
print(cont)
|
||||
if cont:
|
||||
one_msg += f'{cont}\n'
|
||||
send_msg += f'{cont}\n'
|
||||
|
||||
class RUN:
|
||||
def __init__(self,info,index):
|
||||
global one_msg
|
||||
one_msg = ''
|
||||
split_info = info.split('@')
|
||||
self.token = split_info[0]
|
||||
len_split_info = len(split_info)
|
||||
last_info = split_info[len_split_info - 1]
|
||||
self.send_UID = None
|
||||
if len_split_info > 0 and "UID_" in last_info:
|
||||
self.send_UID = last_info
|
||||
self.index = index + 1
|
||||
Log(f"\n---------开始执行第{self.index}个账号>>>>>")
|
||||
self.s = requests.session()
|
||||
self.s.verify = False
|
||||
|
||||
self.headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x6309080f) XWEB/8555',
|
||||
'work-wechat-userid': '',
|
||||
'multi-store-id': '',
|
||||
'gdt-vid': '',
|
||||
'qz-gtd': '',
|
||||
'scene': '1006',
|
||||
'Qm-From': 'wechat',
|
||||
'store-id': '49006',
|
||||
'Qm-User-Token': self.token,
|
||||
'channelCode': '',
|
||||
'Qm-From-Type': 'catering',
|
||||
'promotion-code': '',
|
||||
'work-staff-name': '',
|
||||
'work-staff-id': '',
|
||||
'Accept': 'v=1.0',
|
||||
'Accept-Encoding': 'gzip,compress,br,deflate',
|
||||
'Referer': 'https://servicewechat.com/wxafec6f8422cb357b/87/page-frame.html'
|
||||
}
|
||||
self.s.headers.update(self.headers)
|
||||
self.appid = 'wxafec6f8422cb357b'
|
||||
self.activity_id='947079313798000641'
|
||||
|
||||
def personal_info(self):
|
||||
personal_info_valid = False
|
||||
|
||||
try:
|
||||
# 请求的参数
|
||||
params = {'appid': self.appid}
|
||||
|
||||
# 发送GET请求
|
||||
response = self.s.get('https://webapi.qmai.cn/web/catering/crm/personal-info', json=params)
|
||||
result = response.json()
|
||||
|
||||
# 检查请求是否成功
|
||||
if result.get('code','-1') == '0':
|
||||
personal_info_valid = True
|
||||
# 提取个人信息
|
||||
mobile_phone = result['data']['mobilePhone'] if 'data' in result and 'mobilePhone' in result[
|
||||
'data'] else None
|
||||
self.mobile_phone = mobile_phone[:3] + "*" * 4 + mobile_phone[7:]
|
||||
self.name = result['data']['name'] if 'data' in result and 'name' in result['data'] else None
|
||||
|
||||
Log(f"账号[{self.index}]登陆成功!\n用户名:【{self.name}】 \n手机号:【{self.mobile_phone}】")
|
||||
else:
|
||||
# 如果请求不成功,则打印错误信息
|
||||
message = result.get('message', '')
|
||||
Log(f'登录失败: {message}')
|
||||
|
||||
except Exception as e:
|
||||
# 捕获任何异常并打印
|
||||
print(e)
|
||||
|
||||
finally:
|
||||
# 最终返回请求是否成功的标志
|
||||
return personal_info_valid
|
||||
|
||||
def user_sign_statistics(self):
|
||||
try:
|
||||
|
||||
json_data = {
|
||||
'activityId': self.activity_id,
|
||||
'appid': self.appid
|
||||
}
|
||||
|
||||
# Send the POST request
|
||||
response = self.s.post('https://webapi.qmai.cn/web/cmk-center/sign/userSignStatistics', json=json_data)
|
||||
result = response.json()
|
||||
status_code = response.status_code
|
||||
|
||||
# Check if the request was successful
|
||||
if result.get('code', status_code) == 0:
|
||||
data = result.get('data', {})
|
||||
sign_days = data.get('signDays', '')
|
||||
sign_status = data.get('signStatus', 0) == 1
|
||||
Log(f'新版签到今天{"已" if sign_status else "未"}签到, 已连续签到{sign_days}天')
|
||||
if not sign_status:
|
||||
self.take_part_in_sign()
|
||||
return sign_status, sign_days
|
||||
else:
|
||||
message = result.get('message', '')
|
||||
Log(f'查询新版签到失败: {message}')
|
||||
return False, 0
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return False, 0
|
||||
|
||||
def take_part_in_sign(self):
|
||||
try:
|
||||
json_data = {
|
||||
'activityId': self.activity_id,
|
||||
'appid': self.appid
|
||||
}
|
||||
response = self.s.post('https://webapi.qmai.cn/web/cmk-center/sign/takePartInSign', json=json_data)
|
||||
result = response.json()
|
||||
status_code = response.status_code
|
||||
|
||||
if result.get('code', status_code) == 0:
|
||||
data = result.get('data',{})
|
||||
rewardDetailList = data.get('rewardDetailList',[{}])
|
||||
if rewardDetailList:
|
||||
rewardName = rewardDetailList[0].get('rewardName','')
|
||||
sendNum = rewardDetailList[0].get('sendNum','')
|
||||
Log(f'新版签到成功,获得【{sendNum}】{rewardName}')
|
||||
return True
|
||||
else:
|
||||
Log(f'签到失败:【{result.get("message","")}】')
|
||||
return True
|
||||
else:
|
||||
message = result.get('message', '')
|
||||
Log(f'新版签到失败: {message}')
|
||||
return False
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return False
|
||||
|
||||
def points_info(self):
|
||||
try:
|
||||
json_data = {
|
||||
'appid': self.appid
|
||||
}
|
||||
|
||||
response = self.s.post('https://webapi.qmai.cn/web/catering/crm/points-info', json=json_data)
|
||||
result = response.json()
|
||||
status_code = response.status_code
|
||||
|
||||
if result.get('code', status_code) == '0':
|
||||
data = result.get('data', {})
|
||||
soon_expired_points = data.get('soonExpiredPoints', 0)
|
||||
total_points = data.get('totalPoints', 0)
|
||||
expired_time = data.get('expiredTime', '')
|
||||
|
||||
if soon_expired_points:
|
||||
Log(f'有【{soon_expired_points}】积分将于( {expired_time})过期')
|
||||
|
||||
Log(f'当前积分: 【{total_points}】')
|
||||
return total_points, soon_expired_points, expired_time
|
||||
else:
|
||||
message = result.get('message', '')
|
||||
Log(f'查询积分失败: {message}')
|
||||
return None
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return False
|
||||
|
||||
def main(self):
|
||||
if not self.personal_info() :
|
||||
Log("用户信息无效,请更新CK")
|
||||
return False
|
||||
self.user_sign_statistics()
|
||||
self.points_info()
|
||||
self.sendMsg()
|
||||
return True
|
||||
|
||||
def sendMsg(self, help=False):
|
||||
if self.send_UID:
|
||||
push_res = CHERWIN_TOOLS.wxpusher(self.send_UID, one_msg, APP_NAME, help)
|
||||
print(push_res)
|
||||
|
||||
|
||||
def down_file(filename, file_url):
|
||||
print(f'开始下载:{filename},下载地址:{file_url}')
|
||||
try:
|
||||
response = requests.get(file_url, verify=False, timeout=10)
|
||||
response.raise_for_status()
|
||||
with open(filename + '.tmp', 'wb') as f:
|
||||
f.write(response.content)
|
||||
print(f'【{filename}】下载完成!')
|
||||
|
||||
# 检查临时文件是否存在
|
||||
temp_filename = filename + '.tmp'
|
||||
if os.path.exists(temp_filename):
|
||||
# 删除原有文件
|
||||
if os.path.exists(filename):
|
||||
os.remove(filename)
|
||||
# 重命名临时文件
|
||||
os.rename(temp_filename, filename)
|
||||
print(f'【{filename}】重命名成功!')
|
||||
return True
|
||||
else:
|
||||
print(f'【{filename}】临时文件不存在!')
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f'【{filename}】下载失败:{str(e)}')
|
||||
return False
|
||||
|
||||
def import_Tools():
|
||||
global CHERWIN_TOOLS,ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
|
||||
import CHERWIN_TOOLS
|
||||
ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode = CHERWIN_TOOLS.main(APP_NAME, local_script_name, ENV_NAME,local_version)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
APP_NAME = '霸王茶姬小程序'
|
||||
ENV_NAME = 'BWCJ'
|
||||
CK_NAME = 'qm-user-token'
|
||||
print(f'''
|
||||
✨✨✨ {APP_NAME}签到✨✨✨
|
||||
✨ 功能:
|
||||
积分签到
|
||||
✨ 抓包步骤:
|
||||
打开{APP_NAME}
|
||||
授权登陆
|
||||
打开抓包工具
|
||||
找请求头带{CK_NAME}的URl
|
||||
复制里面的{CK_NAME}参数值
|
||||
✨ ✨✨wxpusher一对一推送功能,
|
||||
✨需要定义变量export WXPUSHER=wxpusher的app_token,不设置则不启用wxpusher一对一推送
|
||||
✨需要在{ENV_NAME}变量最后添加@wxpusher的UID
|
||||
参数示例:Fks8FqmiTksnmZSj2fDvxxxxxxxxx@UID_xxxxx
|
||||
✨ 设置青龙变量:
|
||||
export {ENV_NAME}='{CK_NAME}参数值'多账号#或&分割
|
||||
export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨ ✨ 注意:抓完CK没事儿别打开小程序,重新打开小程序请重新抓包
|
||||
✨ 推荐cron:5 8 * * *
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.04.06'
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://py.cherwin.cn/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://py.cherwin.cn/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
if not token:
|
||||
print(f"未填写{ENV_NAME}变量\n青龙可在环境变量设置 {ENV_NAME} 或者在本脚本文件上方将{CK_NAME}填入token =''")
|
||||
exit()
|
||||
tokens = CHERWIN_TOOLS.ENV_SPLIT(token)
|
||||
# print(tokens)
|
||||
if len(tokens) > 0:
|
||||
print(f"\n>>>>>>>>>>共获取到{len(tokens)}个账号<<<<<<<<<<")
|
||||
for index, infos in enumerate(tokens):
|
||||
run_result = RUN(infos, index).main()
|
||||
if not run_result: continue
|
||||
# !/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
# -------------------------------
|
||||
# cron "30 1 * * *" script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('霸王茶姬小程序')
|
||||
|
||||
import os
|
||||
import requests
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# import CHERWIN_TOOLS
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
else:
|
||||
print("加载通知服务失败!")
|
||||
send_msg = ''
|
||||
one_msg=''
|
||||
def Log(cont=''):
|
||||
global send_msg,one_msg
|
||||
print(cont)
|
||||
if cont:
|
||||
one_msg += f'{cont}\n'
|
||||
send_msg += f'{cont}\n'
|
||||
|
||||
class RUN:
|
||||
def __init__(self,info,index):
|
||||
global one_msg
|
||||
one_msg = ''
|
||||
split_info = info.split('@')
|
||||
self.token = split_info[0]
|
||||
len_split_info = len(split_info)
|
||||
last_info = split_info[len_split_info - 1]
|
||||
self.send_UID = None
|
||||
if len_split_info > 0 and "UID_" in last_info:
|
||||
self.send_UID = last_info
|
||||
self.index = index + 1
|
||||
Log(f"\n---------开始执行第{self.index}个账号>>>>>")
|
||||
self.s = requests.session()
|
||||
self.s.verify = False
|
||||
|
||||
self.headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x6309080f) XWEB/8555',
|
||||
'work-wechat-userid': '',
|
||||
'multi-store-id': '',
|
||||
'gdt-vid': '',
|
||||
'qz-gtd': '',
|
||||
'scene': '1006',
|
||||
'Qm-From': 'wechat',
|
||||
'store-id': '49006',
|
||||
'Qm-User-Token': self.token,
|
||||
'channelCode': '',
|
||||
'Qm-From-Type': 'catering',
|
||||
'promotion-code': '',
|
||||
'work-staff-name': '',
|
||||
'work-staff-id': '',
|
||||
'Accept': 'v=1.0',
|
||||
'Accept-Encoding': 'gzip,compress,br,deflate',
|
||||
'Referer': 'https://servicewechat.com/wxafec6f8422cb357b/87/page-frame.html'
|
||||
}
|
||||
self.s.headers.update(self.headers)
|
||||
self.appid = 'wxafec6f8422cb357b'
|
||||
self.activity_id='947079313798000641'
|
||||
|
||||
def personal_info(self):
|
||||
personal_info_valid = False
|
||||
|
||||
try:
|
||||
# 请求的参数
|
||||
params = {'appid': self.appid}
|
||||
|
||||
# 发送GET请求
|
||||
response = self.s.get('https://webapi.qmai.cn/web/catering/crm/personal-info', json=params)
|
||||
result = response.json()
|
||||
|
||||
# 检查请求是否成功
|
||||
if result.get('code','-1') == '0':
|
||||
personal_info_valid = True
|
||||
# 提取个人信息
|
||||
mobile_phone = result['data']['mobilePhone'] if 'data' in result and 'mobilePhone' in result[
|
||||
'data'] else None
|
||||
self.mobile_phone = mobile_phone[:3] + "*" * 4 + mobile_phone[7:]
|
||||
self.name = result['data']['name'] if 'data' in result and 'name' in result['data'] else None
|
||||
|
||||
Log(f"账号[{self.index}]登陆成功!\n用户名:【{self.name}】 \n手机号:【{self.mobile_phone}】")
|
||||
else:
|
||||
# 如果请求不成功,则打印错误信息
|
||||
message = result.get('message', '')
|
||||
Log(f'登录失败: {message}')
|
||||
|
||||
except Exception as e:
|
||||
# 捕获任何异常并打印
|
||||
print(e)
|
||||
|
||||
finally:
|
||||
# 最终返回请求是否成功的标志
|
||||
return personal_info_valid
|
||||
|
||||
def user_sign_statistics(self):
|
||||
try:
|
||||
|
||||
json_data = {
|
||||
'activityId': self.activity_id,
|
||||
'appid': self.appid
|
||||
}
|
||||
|
||||
# Send the POST request
|
||||
response = self.s.post('https://webapi.qmai.cn/web/cmk-center/sign/userSignStatistics', json=json_data)
|
||||
result = response.json()
|
||||
status_code = response.status_code
|
||||
|
||||
# Check if the request was successful
|
||||
if result.get('code', status_code) == 0:
|
||||
data = result.get('data', {})
|
||||
sign_days = data.get('signDays', '')
|
||||
sign_status = data.get('signStatus', 0) == 1
|
||||
Log(f'新版签到今天{"已" if sign_status else "未"}签到, 已连续签到{sign_days}天')
|
||||
if not sign_status:
|
||||
self.take_part_in_sign()
|
||||
return sign_status, sign_days
|
||||
else:
|
||||
message = result.get('message', '')
|
||||
Log(f'查询新版签到失败: {message}')
|
||||
return False, 0
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return False, 0
|
||||
|
||||
def take_part_in_sign(self):
|
||||
try:
|
||||
json_data = {
|
||||
'activityId': self.activity_id,
|
||||
'appid': self.appid
|
||||
}
|
||||
response = self.s.post('https://webapi.qmai.cn/web/cmk-center/sign/takePartInSign', json=json_data)
|
||||
result = response.json()
|
||||
status_code = response.status_code
|
||||
|
||||
if result.get('code', status_code) == 0:
|
||||
data = result.get('data',{})
|
||||
rewardDetailList = data.get('rewardDetailList',[{}])
|
||||
if rewardDetailList:
|
||||
rewardName = rewardDetailList[0].get('rewardName','')
|
||||
sendNum = rewardDetailList[0].get('sendNum','')
|
||||
Log(f'新版签到成功,获得【{sendNum}】{rewardName}')
|
||||
return True
|
||||
else:
|
||||
Log(f'签到失败:【{result.get("message","")}】')
|
||||
return True
|
||||
else:
|
||||
message = result.get('message', '')
|
||||
Log(f'新版签到失败: {message}')
|
||||
return False
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return False
|
||||
|
||||
def points_info(self):
|
||||
try:
|
||||
json_data = {
|
||||
'appid': self.appid
|
||||
}
|
||||
|
||||
response = self.s.post('https://webapi.qmai.cn/web/catering/crm/points-info', json=json_data)
|
||||
result = response.json()
|
||||
status_code = response.status_code
|
||||
|
||||
if result.get('code', status_code) == '0':
|
||||
data = result.get('data', {})
|
||||
soon_expired_points = data.get('soonExpiredPoints', 0)
|
||||
total_points = data.get('totalPoints', 0)
|
||||
expired_time = data.get('expiredTime', '')
|
||||
|
||||
if soon_expired_points:
|
||||
Log(f'有【{soon_expired_points}】积分将于( {expired_time})过期')
|
||||
|
||||
Log(f'当前积分: 【{total_points}】')
|
||||
return total_points, soon_expired_points, expired_time
|
||||
else:
|
||||
message = result.get('message', '')
|
||||
Log(f'查询积分失败: {message}')
|
||||
return None
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return False
|
||||
|
||||
def main(self):
|
||||
if not self.personal_info() :
|
||||
Log("用户信息无效,请更新CK")
|
||||
self.sendMsg()
|
||||
return False
|
||||
self.user_sign_statistics()
|
||||
self.points_info()
|
||||
self.sendMsg()
|
||||
return True
|
||||
|
||||
def sendMsg(self, help=False):
|
||||
if self.send_UID:
|
||||
push_res = CHERWIN_TOOLS.wxpusher(self.send_UID, one_msg, APP_NAME, help)
|
||||
print(push_res)
|
||||
|
||||
|
||||
def down_file(filename, file_url):
|
||||
print(f'开始下载:{filename},下载地址:{file_url}')
|
||||
try:
|
||||
response = requests.get(file_url, verify=False, timeout=10)
|
||||
response.raise_for_status()
|
||||
with open(filename + '.tmp', 'wb') as f:
|
||||
f.write(response.content)
|
||||
print(f'【{filename}】下载完成!')
|
||||
|
||||
# 检查临时文件是否存在
|
||||
temp_filename = filename + '.tmp'
|
||||
if os.path.exists(temp_filename):
|
||||
# 删除原有文件
|
||||
if os.path.exists(filename):
|
||||
os.remove(filename)
|
||||
# 重命名临时文件
|
||||
os.rename(temp_filename, filename)
|
||||
print(f'【{filename}】重命名成功!')
|
||||
return True
|
||||
else:
|
||||
print(f'【{filename}】临时文件不存在!')
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f'【{filename}】下载失败:{str(e)}')
|
||||
return False
|
||||
|
||||
def import_Tools():
|
||||
global CHERWIN_TOOLS,ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
|
||||
import CHERWIN_TOOLS
|
||||
ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode = CHERWIN_TOOLS.main(APP_NAME, local_script_name, ENV_NAME,local_version)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
APP_NAME = '霸王茶姬小程序'
|
||||
ENV_NAME = 'BWCJ'
|
||||
CK_NAME = 'qm-user-token'
|
||||
print(f'''
|
||||
✨✨✨ {APP_NAME}签到✨✨✨
|
||||
✨ 功能:
|
||||
积分签到
|
||||
✨ 抓包步骤:
|
||||
打开{APP_NAME}
|
||||
授权登陆
|
||||
打开抓包工具
|
||||
找请求头带{CK_NAME}的URl
|
||||
复制里面的{CK_NAME}参数值
|
||||
✨ ✨✨wxpusher一对一推送功能,
|
||||
✨需要定义变量export WXPUSHER=wxpusher的app_token,不设置则不启用wxpusher一对一推送
|
||||
✨需要在{ENV_NAME}变量最后添加@wxpusher的UID
|
||||
参数示例:Fks8FqmiTksnmZSj2fDvxxxxxxxxx@UID_xxxxx
|
||||
✨ 设置青龙变量:
|
||||
export {ENV_NAME}='{CK_NAME}参数值'多账号#或&分割
|
||||
export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨ ✨ 注意:抓完CK没事儿别打开小程序,重新打开小程序请重新抓包
|
||||
✨ 推荐cron:5 8 * * *
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
if not token:
|
||||
print(f"未填写{ENV_NAME}变量\n青龙可在环境变量设置 {ENV_NAME} 或者在本脚本文件上方将{CK_NAME}填入token =''")
|
||||
exit()
|
||||
tokens = CHERWIN_TOOLS.ENV_SPLIT(token)
|
||||
# print(tokens)
|
||||
if len(tokens) > 0:
|
||||
print(f"\n>>>>>>>>>>共获取到{len(tokens)}个账号<<<<<<<<<<")
|
||||
for index, infos in enumerate(tokens):
|
||||
run_result = RUN(infos, index).main()
|
||||
if not run_result: continue
|
||||
if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|
||||
957
CHERWIN_TOOLS.py
957
CHERWIN_TOOLS.py
@ -1,505 +1,452 @@
|
||||
import json
|
||||
import os
|
||||
import importlib.util
|
||||
import subprocess
|
||||
import sys
|
||||
import requests
|
||||
from http import HTTPStatus
|
||||
|
||||
NOW_TOOLS_VERSION = '2024.05.04'
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
|
||||
|
||||
# 尝试导入包
|
||||
def import_or_install(package_name, import_name=None):
|
||||
# 如果传入了 import_name,则使用它来检查模块,否则默认与包名相同
|
||||
import_name = import_name or package_name
|
||||
|
||||
try:
|
||||
# 检查模块是否已安装
|
||||
package_spec = importlib.util.find_spec(import_name)
|
||||
|
||||
if package_spec is None:
|
||||
print(f"{package_name} 模块未安装. 开始安装...")
|
||||
subprocess.check_call([sys.executable, '-m', 'pip', 'install', package_name])
|
||||
print(f"{package_name} 模块安装完成。")
|
||||
else:
|
||||
print(f"{package_name} 模块已安装。")
|
||||
|
||||
# 尝试导入模块检查是否安装成功
|
||||
__import__(import_name)
|
||||
module = importlib.import_module(import_name)
|
||||
print(f"{import_name} 模块导入成功.")
|
||||
return module
|
||||
except ImportError as e:
|
||||
print(f"无法导入 {import_name} 模块. 错误信息: {e}")
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"安装 {package_name} 模块时出错. 错误信息: {e}")
|
||||
except Exception as e:
|
||||
print(f"处理 {package_name} 模块时发生错误. 错误信息: {e}")
|
||||
|
||||
|
||||
def SAVE_INVITE_CODE(file_name, new_data):
|
||||
# 读取现有JSON文件(如果存在)
|
||||
try:
|
||||
with open(file_name, 'r', encoding='utf-8') as file:
|
||||
data = json.load(file)
|
||||
except FileNotFoundError:
|
||||
# 如果文件不存在,创建所需目录并一个新的空JSON文件
|
||||
directory = os.path.dirname(file_name)
|
||||
if not os.path.exists(directory):
|
||||
os.makedirs(directory)
|
||||
data = {}
|
||||
|
||||
# 检查是否已存在相同的键,如果存在,合并数据
|
||||
for key, value in new_data.items():
|
||||
if key in data:
|
||||
# 如果键已存在,将新数据合并到现有数据中
|
||||
data[key].update(value)
|
||||
else:
|
||||
# 如果键不存在,直接插入新数据
|
||||
data[key] = value
|
||||
|
||||
# 将更新后的数据写入JSON文件
|
||||
with open(file_name, 'w', encoding='utf-8') as file:
|
||||
json.dump(data, file, indent=4)
|
||||
|
||||
|
||||
# 将参数转换为字典
|
||||
def create_dict_from_string(self, data_string):
|
||||
params = {}
|
||||
key_value_pairs = data_string.split(',')
|
||||
for pair in key_value_pairs:
|
||||
key, value = pair.split('=')
|
||||
params[key] = value
|
||||
return params
|
||||
|
||||
|
||||
def compare_versions(local_version, server_version):
|
||||
local_parts = local_version.split('.') # 将本地版本号拆分成数字部分
|
||||
server_parts = server_version.split('.') # 将服务器版本号拆分成数字部分
|
||||
|
||||
for l, s in zip(local_parts, server_parts):
|
||||
if int(l) < int(s):
|
||||
return True # 当前版本低于服务器版本
|
||||
elif int(l) > int(s):
|
||||
return False # 当前版本高于服务器版本
|
||||
|
||||
# 如果上述循环没有返回结果,则表示当前版本与服务器版本的数字部分完全相同
|
||||
if len(local_parts) < len(server_parts):
|
||||
return True # 当前版本位数较短,即版本号形如 x.y 比 x.y.z 低
|
||||
else:
|
||||
return False # 当前版本与服务器版本相同或更高
|
||||
|
||||
|
||||
def CHECK_UPDATE(local_version, server_version_url, server_script_url, script_filename):
|
||||
"""
|
||||
检查版本并更新
|
||||
|
||||
Args:
|
||||
local_version (str): 本地版本号
|
||||
server_version_url (str): 服务器版本文件地址
|
||||
server_script_url (str): 服务器脚本地址
|
||||
script_filename (str): 要保存的脚本文件名
|
||||
|
||||
Returns:
|
||||
bool: 是否进行了更新操作
|
||||
"""
|
||||
try:
|
||||
# 获取服务器版本号
|
||||
response = requests.get(server_version_url, verify=False)
|
||||
response.raise_for_status() # Raises an HTTPError for bad responses
|
||||
# print(response.text)
|
||||
server_version = response.text.strip() # 去除首尾空格
|
||||
print(f'当前版本:【{local_version}】')
|
||||
print(f'服务器版本:【{server_version}】')
|
||||
|
||||
if compare_versions(local_version, server_version):
|
||||
# 需要更新,下载服务器脚本
|
||||
AUTO_UPDATE = os.getenv("SCRIPT_UPDATE", "True").lower() != "false"
|
||||
# print(AUTO_UPDATE)
|
||||
if AUTO_UPDATE:
|
||||
print(">>>>>>>发现新版本的脚本,默认自动更新,准备更新...")
|
||||
print(">>>>>>>禁用更新请定义变量export SCRIPT_UPDATE = 'False'")
|
||||
response_script = requests.get(server_script_url, verify=False, timeout=10)
|
||||
response_script.raise_for_status()
|
||||
|
||||
with open(script_filename, 'wb') as f:
|
||||
f.write(response_script.content)
|
||||
print(f'{script_filename} 下载完成!')
|
||||
print(f'尝试运行新脚本')
|
||||
import subprocess, sys
|
||||
# 使用 sys.executable 获取 Python 可执行文件的完整路径
|
||||
python_executable = sys.executable
|
||||
subprocess.Popen([python_executable, script_filename])
|
||||
|
||||
else:
|
||||
print(">>>>>>>发现新版本的脚本,您禁用了自动更新,如需启用请删除变量SCRIPT_UPDATE")
|
||||
else:
|
||||
print(f'当前版本高于或等于服务器版本')
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f'发生网络错误:{e}')
|
||||
|
||||
except Exception as e:
|
||||
print(f'发生未知错误:{e}')
|
||||
|
||||
return False # 返回 False 表示没有进行更新操作
|
||||
|
||||
|
||||
def CHECK_UPDATE_NEW(local_version, server_version, server_script_url, script_filename, server_version_url=None,
|
||||
APP_NAME=None):
|
||||
"""
|
||||
检查版本并更新
|
||||
|
||||
Args:
|
||||
local_version (str): 本地版本号
|
||||
server_version_url (str): 服务器版本文件地址
|
||||
server_script_url (str): 服务器脚本地址
|
||||
script_filename (str): 要保存的脚本文件名
|
||||
|
||||
Returns:
|
||||
bool: 是否进行了更新操作
|
||||
"""
|
||||
print(f'当前检测:【{script_filename}】')
|
||||
try:
|
||||
if server_version_url:
|
||||
# 获取服务器版本号
|
||||
response = requests.get(server_version_url, verify=False)
|
||||
response.raise_for_status() # Raises an HTTPError for bad responses
|
||||
# print(response.text)
|
||||
server_version = response.text.strip() # 去除首尾空格
|
||||
if "code" in server_version:
|
||||
print('【获取远程版本号失败,设为本地同版本】')
|
||||
server_version = local_version
|
||||
if not server_version: server_version = NOW_TOOLS_VERSION
|
||||
print(f'本地版本:【{local_version}】')
|
||||
print(f'服务器版本:【{server_version}】')
|
||||
|
||||
if compare_versions(local_version, server_version):
|
||||
# 需要更新,下载服务器脚本
|
||||
AUTO_UPDATE = os.getenv("SCRIPT_UPDATE", "True").lower() != "false"
|
||||
# print(AUTO_UPDATE)
|
||||
if AUTO_UPDATE:
|
||||
print(">>>>>>>发现新版本的脚本,默认自动更新,准备更新...")
|
||||
print(">>>>>>>禁用更新请定义变量export SCRIPT_UPDATE = 'False'")
|
||||
if down_file(script_filename, server_script_url):
|
||||
print(f'请重新运行新脚本\n')
|
||||
return True
|
||||
else:
|
||||
print(">>>>>>>发现新版本的脚本,您禁用了自动更新,如需启用请删除变量SCRIPT_UPDATE\n")
|
||||
else:
|
||||
print(f'无需更新\n')
|
||||
return False
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f'发生网络错误:{e}')
|
||||
server_base_url = f"https://py.cherwin.cn/{APP_NAME}/"
|
||||
server_script_url = f"{server_base_url}{script_filename}"
|
||||
CHECK_UPDATE_NEW(local_version, server_version, server_script_url, script_filename, APP_NAME=APP_NAME)
|
||||
|
||||
except Exception as e:
|
||||
print(f'发生未知错误:{e}')
|
||||
|
||||
return False # 返回 False 表示没有进行更新操作
|
||||
|
||||
|
||||
def down_file(filename, file_url):
|
||||
print(f'开始下载:{filename},下载地址:{file_url}')
|
||||
try:
|
||||
response = requests.get(file_url, verify=False, timeout=10)
|
||||
response.raise_for_status()
|
||||
with open(filename + '.tmp', 'wb') as f:
|
||||
f.write(response.content)
|
||||
print(f'【{filename}】下载完成!')
|
||||
|
||||
# 检查临时文件是否存在
|
||||
temp_filename = filename + '.tmp'
|
||||
if os.path.exists(temp_filename):
|
||||
# 删除原有文件
|
||||
if os.path.exists(filename):
|
||||
os.remove(filename)
|
||||
# 重命名临时文件
|
||||
os.rename(temp_filename, filename)
|
||||
print(f'【{filename}】重命名成功!')
|
||||
return True
|
||||
else:
|
||||
print(f'【{filename}】临时文件不存在!')
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f'【{filename}】下载失败:{str(e)}')
|
||||
return False
|
||||
|
||||
|
||||
def get_AuthorInviteCode(url):
|
||||
global AuthorCode
|
||||
try:
|
||||
response = requests.get(url, verify=False, timeout=10)
|
||||
if response.status_code == 200:
|
||||
content = json.loads(response.text)
|
||||
AuthorCode = list(content.values())
|
||||
# print(f'获取到作者邀请码:{AuthorCode}')
|
||||
return AuthorCode
|
||||
else:
|
||||
# print("无法获取文件。状态代码:", response.status_code)
|
||||
return {}
|
||||
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
return {}
|
||||
|
||||
|
||||
def GET_TIPS(server_base_url):
|
||||
url = f'{server_base_url}tips.txt'
|
||||
try:
|
||||
response = requests.get(url, verify=False)
|
||||
# 检查响应的编码
|
||||
encoding = response.encoding
|
||||
# print(f"编码: {encoding}")
|
||||
# 设置正确的编码(根据实际情况可能需要调整)
|
||||
response.encoding = 'utf-8'
|
||||
# 读取内容
|
||||
content = response.text
|
||||
if 'code' in content:
|
||||
content = None
|
||||
except:
|
||||
content = None
|
||||
print('获取通知内容失败')
|
||||
if content:
|
||||
return (f'''
|
||||
***********通知内容************\n
|
||||
{content}
|
||||
***********通知内容************\n
|
||||
''')
|
||||
else:
|
||||
return (f'''
|
||||
***********通知内容************\n
|
||||
@Author Cherwin
|
||||
***********通知内容************\n
|
||||
''')
|
||||
|
||||
|
||||
def CHECK_PARAMENTERS(index, input_string, required_parameters):
|
||||
# required_parameters = ['deviceid', 'jysessionid', 'shopid', 'memberid', 'access_token', 'sign']
|
||||
|
||||
# 记录缺少的参数
|
||||
missing_parameters = []
|
||||
|
||||
# 将输入字符串和参数列表中的所有字符都转换为小写
|
||||
input_string_lower = input_string.lower()
|
||||
required_parameters_lower = [param.lower() for param in required_parameters]
|
||||
|
||||
# 判断字符串中是否包含所有必需的参数
|
||||
for param in required_parameters_lower:
|
||||
if param not in input_string_lower:
|
||||
missing_parameters.append(param)
|
||||
|
||||
if missing_parameters:
|
||||
print(f"\n第【{index + 1}】个账号,缺少以下参数:【{missing_parameters}】")
|
||||
return False
|
||||
else:
|
||||
print(f"\n第【{index + 1}】个账号,URL包含所有必需的参数,开始执行脚本")
|
||||
return True
|
||||
|
||||
|
||||
def QIANWEN(tongyiSysPromt, content, api_key):
|
||||
print('开始调用通义千问')
|
||||
# 检查dashscope库是否已安装
|
||||
dashscope = import_or_install('dashscope')
|
||||
if dashscope:
|
||||
dashscope.api_key = api_key
|
||||
response = dashscope.Generation.call(
|
||||
model='qwen-max',
|
||||
messages=[
|
||||
{"role": "system",
|
||||
"content": tongyiSysPromt},
|
||||
{"role": "user", "content": content}],
|
||||
seed=1234,
|
||||
top_p=0.8,
|
||||
result_format='message',
|
||||
enable_search=False,
|
||||
max_tokens=1500,
|
||||
temperature=1.0,
|
||||
repetition_penalty=1.0,
|
||||
)
|
||||
if response.status_code == HTTPStatus.OK:
|
||||
# print(response)
|
||||
video_info = response.output['choices'][0]['message']['content']
|
||||
print('通义生成【成功】!')
|
||||
return video_info
|
||||
else:
|
||||
print(f"无法解析通义返回的信息:{response}")
|
||||
return None
|
||||
else:
|
||||
print('dashscope 模块无法导入,函数无法执行。')
|
||||
|
||||
|
||||
# 取环境变量,并分割
|
||||
def ENV_SPLIT(input_str):
|
||||
parts = []
|
||||
if '&' in input_str:
|
||||
amp_parts = input_str.split('&')
|
||||
for part in amp_parts:
|
||||
if '#' in part:
|
||||
hash_parts = part.split('#')
|
||||
for hash_part in hash_parts:
|
||||
parts.append(hash_part)
|
||||
else:
|
||||
parts.append(part)
|
||||
# print(parts)
|
||||
return (parts)
|
||||
|
||||
elif '#' in input_str:
|
||||
hash_parts = input_str.split('#')
|
||||
# print(hash_parts)
|
||||
return (hash_parts)
|
||||
else:
|
||||
out_str = str(input_str)
|
||||
# print([out_str])
|
||||
return ([out_str])
|
||||
|
||||
|
||||
# 使用导入的模块进行验证码识别
|
||||
def CAPCODE(captcha_slider, captcha_bg):
|
||||
ddddocr = import_or_install('ddddocr')
|
||||
if ddddocr:
|
||||
slide = ddddocr.DdddOcr(det=False, ocr=False)
|
||||
with open(captcha_slider, 'rb') as f:
|
||||
target_bytes = f.read()
|
||||
with open(captcha_bg, 'rb') as f:
|
||||
background_bytes = f.read()
|
||||
res = slide.slide_match(target_bytes, background_bytes, simple_target=True)
|
||||
# print(res['target'][0])
|
||||
# print(type(res['target'][0]))
|
||||
return res['target'][0]
|
||||
else:
|
||||
print('ddddocr 模块无法导入,函数无法执行。')
|
||||
return False
|
||||
|
||||
|
||||
def BASE64_TO_IMG(base64_string, output_path):
|
||||
import base64
|
||||
import io
|
||||
Image = import_or_install('Pillow', 'PIL.Image')
|
||||
|
||||
if Image:
|
||||
try:
|
||||
# 解码base64字符串
|
||||
image_data = base64.b64decode(base64_string)
|
||||
# 将字节数据转换为字节流
|
||||
image_buf = Image.open(io.BytesIO(image_data))
|
||||
# 转换为RGB模式
|
||||
image_buf = image_buf.convert('RGB')
|
||||
# 保存图片到指定路径
|
||||
image_buf.save(output_path, format='JPEG')
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f'发生错误:{e}')
|
||||
return False
|
||||
else:
|
||||
print('需要的模块[PIL]无法导入,函数无法执行。')
|
||||
return False
|
||||
|
||||
|
||||
def send_wxpusher(UID, one_msg, APP_NAME, help=False):
|
||||
WXPUSHER = os.environ.get('WXPUSHER', False)
|
||||
if WXPUSHER:
|
||||
if help:
|
||||
push_res = wxpusher(WXPUSHER, APP_NAME + '互助', one_msg, UID, TIPS_HTML)
|
||||
else:
|
||||
push_res = wxpusher(WXPUSHER, APP_NAME, one_msg, UID, TIPS_HTML)
|
||||
print(push_res)
|
||||
|
||||
|
||||
def wxpusher(UID, msg, title, help=False):
|
||||
"""利用 wxpusher 的 web api 发送 json 数据包,实现微信信息的发送"""
|
||||
WXPUSHER = os.environ.get('WXPUSHER', False)
|
||||
if WXPUSHER:
|
||||
if help: title = title + '互助'
|
||||
print('\n------开始wxpusher推送------')
|
||||
print(f'标题:【{title}】\n内容:{msg}')
|
||||
webapi = 'http://wxpusher.zjiecode.com/api/send/message'
|
||||
msg = msg.replace("\n", "<br>")
|
||||
tips = TIPS_HTML.replace("\n", "<br>")
|
||||
data = {
|
||||
"appToken": WXPUSHER,
|
||||
"content": f'{title}<br>{msg}<br>{tips}',
|
||||
# "summary": msg[:99], # 该参数可选,默认为 msg 的前10个字符
|
||||
"summary": title,
|
||||
"contentType": 2,
|
||||
"uids": [UID],
|
||||
"url": "https://gj.cherwin.cn"
|
||||
}
|
||||
|
||||
try:
|
||||
result = requests.post(url=webapi, json=data)
|
||||
result.raise_for_status() # 对于非2xx状态码,抛出异常
|
||||
response_json = result.json()
|
||||
if response_json["success"]:
|
||||
return "------消息发送成功------\n"
|
||||
else:
|
||||
return f"消息发送失败。错误信息:{response_json['msg']}"
|
||||
except requests.exceptions.RequestException as e:
|
||||
return f"发送消息时发生错误:{str(e)}"
|
||||
except Exception as e:
|
||||
return f"发生意外错误:{str(e)}"
|
||||
|
||||
|
||||
def RESTART_SCRIPT(RESTART_SCRIPT_NAME):
|
||||
python = sys.executable
|
||||
os.execl(python, RESTART_SCRIPT_NAME, *sys.argv[1:])
|
||||
|
||||
|
||||
def CHECK():
|
||||
global CHERWIN_SCRIPT_CONFIG
|
||||
print('>>>>>>>开始获取版本信息...')
|
||||
baseurl = 'https://py.cherwin.cn/'
|
||||
TOOLS_NAME = 'CHERWIN_TOOLS.py'
|
||||
server_script_url = f'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/{TOOLS_NAME}'
|
||||
try:
|
||||
response = requests.get(f'{baseurl}CHERWIN_SCRIPT_CONFIG.json', verify=False)
|
||||
response.encoding = 'utf-8'
|
||||
# 读取内容
|
||||
CHERWIN_SCRIPT_CONFIG = response.json()
|
||||
if 'code' in CHERWIN_SCRIPT_CONFIG:
|
||||
CHERWIN_SCRIPT_CONFIG = None
|
||||
server_version = CHERWIN_SCRIPT_CONFIG.get('TOOLS_VERSION', NOW_TOOLS_VERSION)
|
||||
if CHECK_UPDATE_NEW(NOW_TOOLS_VERSION, server_version, server_script_url, TOOLS_NAME):
|
||||
print('更新脚本完成')
|
||||
# print(f'重新检测[{TOOLS_NAME}]版本')
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
except:
|
||||
print('获取CHERWIN_SCRIPT_CONFIG.json失败')
|
||||
return False
|
||||
|
||||
|
||||
def main(APP_NAME, local_script_name, ENV_NAME, local_version):
|
||||
global APP_INFO, TIPS, TIPS_HTML
|
||||
git_url = f'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/{local_script_name}'
|
||||
if CHECK():
|
||||
APP_INFO = CHERWIN_SCRIPT_CONFIG.get("APP_CONFIG", {}).get(ENV_NAME, {})
|
||||
# print(APP_INFO)
|
||||
server_version = APP_INFO.get('NEW_VERSION', '')
|
||||
if CHECK_UPDATE_NEW(local_version, server_version, git_url, local_script_name, APP_NAME=APP_NAME):
|
||||
print('更新成功,请重新运行脚本!')
|
||||
|
||||
if not APP_INFO.get('ENABLE', False):
|
||||
print('当前脚本未开放')
|
||||
exit()
|
||||
TIPS = APP_INFO.get('NTC', '') if APP_INFO.get('NTC', '') else CHERWIN_SCRIPT_CONFIG.get('GLOBAL_NTC', '')
|
||||
|
||||
TIPS_HTML = APP_INFO.get('NTC', '') if APP_INFO.get('NTC', '') else CHERWIN_SCRIPT_CONFIG.get('GLOBAL_NTC_HTML',
|
||||
'')
|
||||
ENV = os.environ.get(ENV_NAME)
|
||||
AuthorCode = get_AuthorInviteCode(f'https://yhsh.ziyuand.cn/{ENV_NAME}_INVITE_CODE.json')
|
||||
|
||||
return ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
|
||||
else:
|
||||
exit()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pass
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import importlib.util
|
||||
import random
|
||||
import string
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import requests
|
||||
from http import HTTPStatus
|
||||
from datetime import datetime
|
||||
|
||||
NOW_TOOLS_VERSION = '2024.05.15'
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
else:
|
||||
IS_DEV = False
|
||||
|
||||
|
||||
# 尝试导入包
|
||||
def import_or_install(package_name, import_name=None):
|
||||
# 如果传入了 import_name,则使用它来检查模块,否则默认与包名相同
|
||||
import_name = import_name or package_name
|
||||
try:
|
||||
# 检查模块是否已安装
|
||||
package_spec = importlib.util.find_spec(import_name)
|
||||
if package_spec is None:
|
||||
print(f"{package_name} 模块未安装. 开始安装...")
|
||||
subprocess.check_call([sys.executable, '-m', 'pip', 'install', package_name])
|
||||
print(f"{package_name} 模块安装完成。")
|
||||
else:
|
||||
print(f"{package_name} 模块已安装。")
|
||||
# 尝试导入模块检查是否安装成功
|
||||
__import__(import_name)
|
||||
module = importlib.import_module(import_name)
|
||||
print(f"{import_name} 模块导入成功.")
|
||||
return module
|
||||
except ImportError as e:
|
||||
print(f"无法导入 {import_name} 模块. 错误信息: {e}")
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"安装 {package_name} 模块时出错. 错误信息: {e}")
|
||||
except Exception as e:
|
||||
print(f"处理 {package_name} 模块时发生错误. 错误信息: {e}")
|
||||
|
||||
|
||||
def SAVE_INVITE_CODE(file_name, new_data):
|
||||
# 读取现有JSON文件(如果存在)
|
||||
try:
|
||||
with open(file_name, 'r', encoding='utf-8') as file:
|
||||
data = json.load(file)
|
||||
except FileNotFoundError:
|
||||
# 如果文件不存在,创建所需目录并一个新的空JSON文件
|
||||
directory = os.path.dirname(file_name)
|
||||
if not os.path.exists(directory):
|
||||
os.makedirs(directory)
|
||||
data = {}
|
||||
# 检查是否已存在相同的键,如果存在,合并数据
|
||||
for key, value in new_data.items():
|
||||
if key in data:
|
||||
# 如果键已存在,将新数据合并到现有数据中
|
||||
data[key].update(value)
|
||||
else:
|
||||
# 如果键不存在,直接插入新数据
|
||||
data[key] = value
|
||||
# 将更新后的数据写入JSON文件
|
||||
with open(file_name, 'w', encoding='utf-8') as file:
|
||||
json.dump(data, file, indent=4)
|
||||
|
||||
|
||||
# 将参数转换为字典
|
||||
def create_dict_from_string(self, data_string):
|
||||
params = {}
|
||||
key_value_pairs = data_string.split(',')
|
||||
for pair in key_value_pairs:
|
||||
key, value = pair.split('=')
|
||||
params[key] = value
|
||||
return params
|
||||
|
||||
|
||||
def compare_versions(local_version, server_version):
|
||||
local_parts = local_version.split('.') # 将本地版本号拆分成数字部分
|
||||
server_parts = server_version.split('.') # 将服务器版本号拆分成数字部分
|
||||
for l, s in zip(local_parts, server_parts):
|
||||
if int(l) < int(s):
|
||||
return True
|
||||
# 当前版本低于服务器版本
|
||||
elif int(l) > int(s):
|
||||
return False
|
||||
# 当前版本高于服务器版本
|
||||
# 如果上述循环没有返回结果,则表示当前版本与服务器版本的数字部分完全相同
|
||||
if len(local_parts) < len(server_parts):
|
||||
return True # 当前版本位数较短,即版本号形如 x.y 比 x.y.z 低
|
||||
else:
|
||||
return False # 当前版本与服务器版本相同或更高
|
||||
|
||||
|
||||
|
||||
def CHECK_UPDATE_NEW(local_version, server_version, server_script_url, script_filename, server_version_url=None,
|
||||
APP_NAME=None):
|
||||
"""
|
||||
检查版本并更新
|
||||
|
||||
Args:
|
||||
local_version (str): 本地版本号
|
||||
server_version_url (str): 服务器版本文件地址
|
||||
server_script_url (str): 服务器脚本地址
|
||||
script_filename (str): 要保存的脚本文件名
|
||||
|
||||
Returns:
|
||||
bool: 是否进行了更新操作
|
||||
"""
|
||||
print(f'当前检测:【{script_filename}】')
|
||||
try:
|
||||
if server_version_url:
|
||||
# 获取服务器版本号
|
||||
response = requests.get(server_version_url, verify=False)
|
||||
response.raise_for_status() # Raises an HTTPError for bad responses
|
||||
# print(response.text)
|
||||
server_version = response.text.strip() # 去除首尾空格
|
||||
if "code" in server_version:
|
||||
print('【获取远程版本号失败,设为本地同版本】')
|
||||
server_version = local_version
|
||||
if not server_version: server_version = NOW_TOOLS_VERSION
|
||||
print(f'本地版本:【{local_version}】')
|
||||
print(f'服务器版本:【{server_version}】')
|
||||
if compare_versions(local_version, server_version):
|
||||
# 需要更新,下载服务器脚本
|
||||
AUTO_UPDATE = os.getenv("SCRIPT_UPDATE", "True").lower() != "false"
|
||||
# print(AUTO_UPDATE)
|
||||
if AUTO_UPDATE:
|
||||
print(">>>>>>>发现新版本的脚本,默认自动更新,准备更新...")
|
||||
print(">>>>>>>禁用更新请定义变量export SCRIPT_UPDATE = 'False'")
|
||||
if down_file(script_filename, server_script_url):
|
||||
print(f'请重新运行新脚本\n')
|
||||
return True
|
||||
else:
|
||||
print(">>>>>>>发现新版本的脚本,您禁用了自动更新,如需启用请删除变量SCRIPT_UPDATE\n")
|
||||
else:
|
||||
print(f'无需更新\n')
|
||||
return False
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f'发生网络错误:{e}')
|
||||
server_base_url = f"https://py.cherwin.cn/{APP_NAME}/"
|
||||
server_script_url = f"{server_base_url}{script_filename}"
|
||||
CHECK_UPDATE_NEW(local_version, server_version, server_script_url, script_filename, APP_NAME=APP_NAME)
|
||||
except Exception as e:
|
||||
print(f'发生未知错误:{e}')
|
||||
return False # 返回 False 表示没有进行更新操作
|
||||
|
||||
|
||||
def down_file(filename, file_url):
|
||||
print(f'开始下载:{filename},下载地址:{file_url}')
|
||||
try:
|
||||
response = requests.get(file_url, verify=False, timeout=10)
|
||||
response.raise_for_status()
|
||||
with open(filename + '.tmp', 'wb') as f:
|
||||
f.write(response.content)
|
||||
print(f'【{filename}】下载完成!')
|
||||
# 检查临时文件是否存在
|
||||
temp_filename = filename + '.tmp'
|
||||
if os.path.exists(temp_filename):
|
||||
# 删除原有文件
|
||||
if os.path.exists(filename):
|
||||
os.remove(filename)
|
||||
# 重命名临时文件
|
||||
os.rename(temp_filename, filename)
|
||||
print(f'【{filename}】重命名成功!')
|
||||
return True
|
||||
else:
|
||||
print(f'【{filename}】临时文件不存在!')
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f'【{filename}】下载失败:{str(e)}')
|
||||
return False
|
||||
|
||||
|
||||
def get_AuthorInviteCode(url):
|
||||
global AuthorCode
|
||||
try:
|
||||
response = requests.get(url, verify=False, timeout=10)
|
||||
if response.status_code == 200:
|
||||
content = json.loads(response.text)
|
||||
AuthorCode = list(content.values())
|
||||
# print(f'获取到作者邀请码:{AuthorCode}')
|
||||
return AuthorCode
|
||||
else:
|
||||
# print("无法获取文件。状态代码:", response.status_code)
|
||||
return {}
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
return {}
|
||||
|
||||
|
||||
|
||||
def CHECK_PARAMENTERS(index, input_string, required_parameters):
|
||||
# required_parameters = ['deviceid', 'jysessionid', 'shopid', 'memberid', 'access_token', 'sign']
|
||||
|
||||
# 记录缺少的参数
|
||||
missing_parameters = []
|
||||
# 将输入字符串和参数列表中的所有字符都转换为小写
|
||||
input_string_lower = input_string.lower()
|
||||
required_parameters_lower = [param.lower() for param in required_parameters]
|
||||
# 判断字符串中是否包含所有必需的参数
|
||||
for param in required_parameters_lower:
|
||||
if param not in input_string_lower:
|
||||
missing_parameters.append(param)
|
||||
if missing_parameters:
|
||||
print(f"\n第【{index + 1}】个账号,缺少以下参数:【{missing_parameters}】")
|
||||
return False
|
||||
else:
|
||||
print(f"\n第【{index + 1}】个账号,URL包含所有必需的参数,开始执行脚本")
|
||||
return True
|
||||
|
||||
|
||||
def QIANWEN(tongyiSysPromt, content, api_key):
|
||||
print('开始调用通义千问')
|
||||
# 检查dashscope库是否已安装
|
||||
dashscope = import_or_install('dashscope')
|
||||
if dashscope:
|
||||
dashscope.api_key = api_key
|
||||
response = dashscope.Generation.call(
|
||||
model='qwen-max',
|
||||
messages=[
|
||||
{"role": "system",
|
||||
"content": tongyiSysPromt},
|
||||
{"role": "user", "content": content}],
|
||||
seed=1234,
|
||||
top_p=0.8,
|
||||
result_format='message',
|
||||
enable_search=False,
|
||||
max_tokens=1500,
|
||||
temperature=1.0,
|
||||
repetition_penalty=1.0,
|
||||
)
|
||||
if response.status_code == HTTPStatus.OK:
|
||||
# print(response)
|
||||
video_info = response.output['choices'][0]['message']['content']
|
||||
print('通义生成【成功】!')
|
||||
return video_info
|
||||
else:
|
||||
print(f"无法解析通义返回的信息:{response}")
|
||||
return None
|
||||
else:
|
||||
print('dashscope 模块无法导入,函数无法执行。')
|
||||
|
||||
|
||||
# 取环境变量,并分割
|
||||
def ENV_SPLIT(input_str):
|
||||
parts = []
|
||||
if '&' in input_str:
|
||||
amp_parts = input_str.split('&')
|
||||
for part in amp_parts:
|
||||
if '#' in part:
|
||||
hash_parts = part.split('#')
|
||||
for hash_part in hash_parts:
|
||||
parts.append(hash_part)
|
||||
else:
|
||||
parts.append(part)
|
||||
# print(parts)
|
||||
return (parts)
|
||||
|
||||
elif '#' in input_str:
|
||||
hash_parts = input_str.split('#')
|
||||
# print(hash_parts)
|
||||
return (hash_parts)
|
||||
else:
|
||||
out_str = str(input_str)
|
||||
# print([out_str])
|
||||
return ([out_str])
|
||||
|
||||
|
||||
# 使用导入的模块进行验证码识别
|
||||
def CAPCODE(captcha_slider, captcha_bg):
|
||||
ddddocr = import_or_install('ddddocr')
|
||||
if ddddocr:
|
||||
slide = ddddocr.DdddOcr(det=False, ocr=False)
|
||||
with open(captcha_slider, 'rb') as f:
|
||||
target_bytes = f.read()
|
||||
with open(captcha_bg, 'rb') as f:
|
||||
background_bytes = f.read()
|
||||
res = slide.slide_match(target_bytes, background_bytes, simple_target=True)
|
||||
# print(res['target'][0])
|
||||
# print(type(res['target'][0]))
|
||||
return res['target'][0]
|
||||
else:
|
||||
print('ddddocr 模块无法导入,函数无法执行。')
|
||||
return False
|
||||
|
||||
|
||||
def send_wxpusher(UID, one_msg, APP_NAME, help=False):
|
||||
WXPUSHER = os.environ.get('WXPUSHER', False)
|
||||
if WXPUSHER:
|
||||
if help:
|
||||
push_res = wxpusher(WXPUSHER, APP_NAME + '互助', one_msg, UID, TIPS_HTML)
|
||||
else:
|
||||
push_res = wxpusher(WXPUSHER, APP_NAME, one_msg, UID, TIPS_HTML)
|
||||
print(push_res)
|
||||
|
||||
|
||||
def wxpusher(UID, msg, title, help=False):
|
||||
"""利用 wxpusher 的 web api 发送 json 数据包,实现微信信息的发送"""
|
||||
WXPUSHER = os.environ.get('WXPUSHER', False)
|
||||
if WXPUSHER:
|
||||
if help: title = title + '互助'
|
||||
print('\n------开始wxpusher推送------')
|
||||
print(f'标题:【{title}】\n内容:{msg}')
|
||||
webapi = 'http://wxpusher.zjiecode.com/api/send/message'
|
||||
msg = msg.replace("\n", "<br>")
|
||||
# tips = TIPS_HTML.replace("\n", "<br>")
|
||||
data = {
|
||||
"appToken": WXPUSHER,
|
||||
"content": f'{title}<br>{msg}<br>{TIPS_HTML}',
|
||||
# "summary": msg[:99], # 该参数可选,默认为 msg 的前10个字符
|
||||
"summary": title,
|
||||
"contentType": 2,
|
||||
"uids": [UID],
|
||||
"url": "https://gj.cherwin.cn"
|
||||
}
|
||||
try:
|
||||
result = requests.post(url=webapi, json=data)
|
||||
result.raise_for_status() # 对于非2xx状态码,抛出异常
|
||||
response_json = result.json()
|
||||
if response_json["success"]:
|
||||
return "------消息发送成功------\n"
|
||||
else:
|
||||
return f"消息发送失败。错误信息:{response_json['msg']}"
|
||||
except requests.exceptions.RequestException as e:
|
||||
return f"发送消息时发生错误:{str(e)}"
|
||||
except Exception as e:
|
||||
return f"发生意外错误:{str(e)}"
|
||||
|
||||
|
||||
def RESTART_SCRIPT(RESTART_SCRIPT_NAME):
|
||||
python = sys.executable
|
||||
os.execl(python, RESTART_SCRIPT_NAME, *sys.argv[1:])
|
||||
|
||||
|
||||
def CHECK():
|
||||
global CHERWIN_SCRIPT_CONFIG
|
||||
print('>>>>>>>开始获取版本信息...')
|
||||
baseurl = 'https://py.cherwin.cn/'
|
||||
TOOLS_NAME = 'CHERWIN_TOOLS.py'
|
||||
server_script_url = f'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/{TOOLS_NAME}'
|
||||
try:
|
||||
response = requests.get(f'{baseurl}CHERWIN_SCRIPT_CONFIG.json', verify=False)
|
||||
response.encoding = 'utf-8'
|
||||
# 读取内容
|
||||
CHERWIN_SCRIPT_CONFIG = response.json()
|
||||
if 'code' in CHERWIN_SCRIPT_CONFIG:
|
||||
CHERWIN_SCRIPT_CONFIG = None
|
||||
server_version = CHERWIN_SCRIPT_CONFIG.get('TOOLS_VERSION', NOW_TOOLS_VERSION)
|
||||
if CHECK_UPDATE_NEW(NOW_TOOLS_VERSION, server_version, server_script_url, TOOLS_NAME):
|
||||
print('更新脚本完成')
|
||||
# print(f'重新检测[{TOOLS_NAME}]版本')
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
except:
|
||||
print('获取CHERWIN_SCRIPT_CONFIG.json失败')
|
||||
return False
|
||||
def GJJJ_SIGN():
|
||||
app_id = "667516"
|
||||
app_crypto = "FH3yRrHG2RfexND8"
|
||||
timestamp = int(time.time() * 1000)
|
||||
# timestamp = 1715180892075
|
||||
text = f"{app_id}{app_crypto}{timestamp}"
|
||||
sign = hashlib.md5(text.encode()).hexdigest()
|
||||
new_data = {
|
||||
'timestamp': str(timestamp),
|
||||
"sign": sign
|
||||
}
|
||||
return new_data
|
||||
def KWW_SIGN(memberId):
|
||||
timestamp = int(time.time() * 1000)
|
||||
random_num = random.randint(0, 31)
|
||||
u = [
|
||||
"A", "Z", "B", "Y", "C", "X", "D", "T", "E", "S", "F", "R", "G", "Q", "H", "P", "I", "O", "J", "N", "k",
|
||||
"M", "L", "a", "c", "d", "f", "h", "k", "p", "y", "n"]
|
||||
r = f"{timestamp}{memberId}{u[random_num]}"
|
||||
sign = hashlib.md5(r.encode()).hexdigest()
|
||||
update_headers = {
|
||||
"user-sign": sign,
|
||||
"user-paramname": "memberId",
|
||||
"user-timestamp": str(timestamp),
|
||||
"user-random": str(random_num)
|
||||
}
|
||||
return update_headers
|
||||
def TYQH_SIGN(parameters={}, body=None):
|
||||
sorted_keys = sorted(parameters.keys())
|
||||
parameter_strings = []
|
||||
for key in sorted_keys:
|
||||
if isinstance(parameters[key], dict):
|
||||
parameter_strings.append(f"{key}={json.dumps(parameters[key])}")
|
||||
else:
|
||||
parameter_strings.append(f"{key}={parameters[key]}")
|
||||
|
||||
current_time = int(datetime.now().timestamp() * 1000)
|
||||
secret_chars = list('BxzTx45uIGT25TTHIIBU2')
|
||||
last_three_digits = str(current_time)[-3:]
|
||||
for digit in last_three_digits:
|
||||
secret_chars.insert(int(digit), digit)
|
||||
|
||||
secret = hashlib.md5(''.join(secret_chars).encode()).hexdigest()
|
||||
nonce_str = ''.join(random.choices(string.ascii_letters + string.digits, k=16))
|
||||
|
||||
sign_data = {
|
||||
'client_id': 'game',
|
||||
'nonstr': nonce_str,
|
||||
'timestamp': current_time,
|
||||
'body': json.dumps(body) if body else '',
|
||||
'query': '&'.join(parameter_strings) if parameter_strings else '',
|
||||
'secret': secret
|
||||
}
|
||||
|
||||
sign_string = '|'.join([str(v) for v in sign_data.values()])
|
||||
sign = hashlib.md5(sign_string.encode()).hexdigest().upper()
|
||||
sign_header = {
|
||||
'client_id': 'game',
|
||||
'timestamp': str(current_time),
|
||||
'nonstr': sign_data['nonstr'],
|
||||
'sign': sign
|
||||
}
|
||||
return sign_header
|
||||
|
||||
def main(APP_NAME, local_script_name, ENV_NAME, local_version,need_invite=False):
|
||||
global APP_INFO, TIPS, TIPS_HTML
|
||||
git_url = f'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/{local_script_name}'
|
||||
if CHECK():
|
||||
APP_INFO = CHERWIN_SCRIPT_CONFIG.get("APP_CONFIG", {}).get(ENV_NAME, {})
|
||||
# print(APP_INFO)
|
||||
server_version = APP_INFO.get('NEW_VERSION', '')
|
||||
if CHECK_UPDATE_NEW(local_version, server_version, git_url, local_script_name, APP_NAME=APP_NAME):
|
||||
print('更新成功,请重新运行脚本!')
|
||||
|
||||
if not APP_INFO.get('ENABLE', False) and not IS_DEV:
|
||||
print('当前脚本未开放')
|
||||
exit()
|
||||
TIPS = APP_INFO.get('NTC', '') if APP_INFO.get('NTC', '') else CHERWIN_SCRIPT_CONFIG.get('GLOBAL_NTC', '')
|
||||
TIPS_HTML = APP_INFO.get('NTC', '') if APP_INFO.get('NTC', '') else CHERWIN_SCRIPT_CONFIG.get('GLOBAL_NTC_HTML','')
|
||||
ENV = os.environ.get(ENV_NAME)
|
||||
if need_invite:
|
||||
AuthorCode = get_AuthorInviteCode(f'https://yhsh.ziyuand.cn/{ENV_NAME}_INVITE_CODE.json')
|
||||
else:
|
||||
AuthorCode = ''
|
||||
return ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
|
||||
else:
|
||||
exit()
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(NOW_TOOLS_VERSION)
|
||||
89
DBKD.py
89
DBKD.py
@ -3,8 +3,8 @@
|
||||
# -------------------------------
|
||||
# ✨✨✨ @Author CHERWIN✨✨✨
|
||||
# -------------------------------
|
||||
# cron "0 7 * * *" script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('德邦快递小程序签到')
|
||||
# cron "0 6 * * *" script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('中通快递小程序签到')
|
||||
|
||||
import os
|
||||
import requests
|
||||
@ -13,9 +13,10 @@ from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
@ -46,14 +47,12 @@ class RUN:
|
||||
self.index = index + 1
|
||||
self.s = requests.session()
|
||||
self.s.verify = False
|
||||
|
||||
self.token = token
|
||||
self.token = f'ECO_TOKEN={token};'
|
||||
self.headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x6309080f) XWEB/9079',
|
||||
'Cookie':self.token,
|
||||
'Referer': 'https://servicewechat.com/wxa1ebeeb0ed47f0b2/633/page-frame.html'
|
||||
}
|
||||
self.baseUrl = 'https://api.ztomember.com/api/'
|
||||
|
||||
|
||||
def do_request(self, method, url, params=None, data=None, headers=None):
|
||||
if not headers:
|
||||
@ -86,6 +85,26 @@ class RUN:
|
||||
print(f"查询账户异常: {e}")
|
||||
return False
|
||||
|
||||
def queryUserInfo(self):
|
||||
try:
|
||||
self.headers['Content-Type'] = 'application/json'
|
||||
self.headers['Accept'] = '*/*'
|
||||
response = self.do_request('GET', 'https://www.deppon.com/ndcc-gwapi/userService/eco/user/secure/queryUserInfo')
|
||||
if response and response.get('message') == 'ok':
|
||||
# print(response)
|
||||
result = response.get('result', {})
|
||||
phone = result.get('mobile', '')
|
||||
self.mobile = phone[:3] + "*" * 4 + phone[7:]
|
||||
self.userName = result.get('userName', '')
|
||||
Log(f'\n用户名:【{self.userName}】\n手机号:【{self.mobile}】')
|
||||
return True
|
||||
else:
|
||||
Log(f"登录验证失败: {response}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"登录验证异常: {e}")
|
||||
return False
|
||||
|
||||
def generate_tmp_token(self):
|
||||
try:
|
||||
response = self.do_request('GET', 'https://www.deppon.com/ndcc-gwapi/userService/eco/user/token/secure/generateTmpToken')
|
||||
@ -107,11 +126,11 @@ class RUN:
|
||||
if response and response.get('code') == 200:
|
||||
# print(response)
|
||||
Log(f"登录验证成功!")
|
||||
self.phone = response['data']['mobile']
|
||||
self.token = response['data']['token']
|
||||
self.headers['mobile'] = self.phone
|
||||
data = response.get('data', {})
|
||||
self.token = data.get('token','')
|
||||
self.phone = data.get('mobile','')
|
||||
self.headers['token'] = self.token
|
||||
#
|
||||
self.headers['mobile'] = self.phone
|
||||
# print(f"PHONE:【{self.phone}】")
|
||||
# print(f"TOKEN:【{self.token}】")
|
||||
return True
|
||||
@ -248,7 +267,7 @@ class RUN:
|
||||
"rightsClaimStatus":1,
|
||||
"taskRuleId":self.taskRuleId
|
||||
}
|
||||
response = self.do_request('POST', 'https://mas.deppon.com/crm-api/deppon/pay/member/add/package/query',data = data)
|
||||
response = self.do_request('POST', 'https://mas.deppon.com/crm-api/deppon/points/task/changeStatus',data = data)
|
||||
if response and response.get('code') == 200:
|
||||
Log(f'完成任务:【{self.name}】成功!')
|
||||
return response['msg']
|
||||
@ -276,14 +295,15 @@ class RUN:
|
||||
|
||||
def lottery(self):
|
||||
try:
|
||||
data = {"phone": self.phone,"gameId":'Zv8i7IsOPZIQrvvupKXE1w=='}
|
||||
response = self.do_request('POST', 'https://mas.deppon.com/crm-api/game/draw/lottery',data = data)
|
||||
data = {"mobile": self.phone,"gameId":'67'}
|
||||
response = self.do_request('POST', 'https://mas.deppon.com/admin/envelops/game/lottery',data = data)
|
||||
|
||||
if response and response.get('code') == 200:
|
||||
print('抽奖成功')
|
||||
print(response)
|
||||
self.pointsAvailableValue -= 1
|
||||
return response['msg']
|
||||
if response and response.get('code') == 0:
|
||||
# print(response)
|
||||
data = response.get('data','')
|
||||
name = data.get('name','')
|
||||
Log(f'抽奖成功,获得:{name}')
|
||||
return
|
||||
else:
|
||||
print(f"抽奖失败: {response}")
|
||||
return None
|
||||
@ -318,16 +338,20 @@ class RUN:
|
||||
|
||||
def main(self):
|
||||
Log(f"\n开始执行第{self.index}个账号--------------->>>>>")
|
||||
if self.login():
|
||||
# if self.login():
|
||||
|
||||
if self.queryUserInfo():
|
||||
self.generate_tmp_token()
|
||||
self.getSvipNewestInfo()
|
||||
self.signIn_info()
|
||||
self.points_signIn_info()
|
||||
self.task_list()
|
||||
self.lottery_query2()
|
||||
self.lottery()
|
||||
self.getSvipNewestInfo('执行后')
|
||||
self.sendMsg()
|
||||
return True
|
||||
else:
|
||||
self.sendMsg()
|
||||
return False
|
||||
|
||||
def sendMsg(self):
|
||||
@ -374,8 +398,8 @@ def import_Tools():
|
||||
if __name__ == '__main__':
|
||||
APP_NAME = '德邦快递小程序'
|
||||
ENV_NAME = 'DBKD'
|
||||
CK_NAME = 'code'
|
||||
CK_URL = 'https://www.deppon.com/ndcc-gwapi/userService/eco/user/login'
|
||||
CK_NAME = 'ECO_TOKEN=里面的值;'
|
||||
CK_URL = 'https://www.deppon.com/ndcc-gwapi/userService/eco/user/secure/queryUserInfo'
|
||||
print(f'''
|
||||
✨✨✨ {APP_NAME}签到✨✨✨
|
||||
✨ 功能:
|
||||
@ -384,7 +408,7 @@ if __name__ == '__main__':
|
||||
打开{APP_NAME}
|
||||
授权登陆
|
||||
打开抓包工具
|
||||
找{CK_URL}请求body里面的[{CK_NAME}]
|
||||
找{CK_URL}请求Cookies里面的[{CK_NAME}]
|
||||
复制里面的[{CK_NAME}]参数值
|
||||
参数示例:0f1bjLFa1ZdedHxxxxxxxx
|
||||
✨ ✨✨wxpusher一对一推送功能,
|
||||
@ -398,16 +422,19 @@ export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.04.18'
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://py.cherwin.cn/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://py.cherwin.cn/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
@ -422,4 +449,4 @@ export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
for index, infos in enumerate(tokens):
|
||||
run_result = RUN(infos, index).main()
|
||||
if not run_result: continue
|
||||
if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|
||||
# if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|
||||
274
EMS.py
Executable file
274
EMS.py
Executable file
@ -0,0 +1,274 @@
|
||||
# !/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
# -------------------------------
|
||||
# ✨✨✨ @Author CHERWIN✨✨✨
|
||||
# -------------------------------
|
||||
# cron "0 10 * * *" script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('EMS邮惠中心小程序')
|
||||
|
||||
import os
|
||||
import requests
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
else:
|
||||
print("加载通知服务失败!")
|
||||
send_msg = ''
|
||||
one_msg=''
|
||||
def Log(cont=''):
|
||||
global send_msg,one_msg
|
||||
print(cont)
|
||||
if cont:
|
||||
one_msg += f'{cont}\n'
|
||||
send_msg += f'{cont}\n'
|
||||
|
||||
class RUN:
|
||||
def __init__(self,info,index):
|
||||
global one_msg
|
||||
one_msg = ''
|
||||
split_info = info.split('@')
|
||||
token = split_info[0]
|
||||
len_split_info = len(split_info)
|
||||
last_info = split_info[len_split_info - 1]
|
||||
self.send_UID = None
|
||||
if len_split_info > 0 and "UID_" in last_info:
|
||||
print('检测到设置了UID')
|
||||
print(last_info)
|
||||
self.send_UID = last_info
|
||||
self.index = index + 1
|
||||
self.s = requests.session()
|
||||
self.s.verify = False
|
||||
self.openId = token
|
||||
self.headers = {
|
||||
'Host': 'ump.ems.com.cn',
|
||||
'Upgrade-Insecure-Requests': '1',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF XWEB/6945',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
|
||||
'Sec-Fetch-Site': 'none',
|
||||
'Sec-Fetch-Mode': 'navigate',
|
||||
'Sec-Fetch-User': '?1',
|
||||
'Sec-Fetch-Dest': 'document',
|
||||
'Accept-Language': 'zh-CN,zh',
|
||||
}
|
||||
|
||||
|
||||
def do_request(self, url, method="POST",params=None, data=None, headers=None):
|
||||
if not headers:
|
||||
headers = self.headers
|
||||
try:
|
||||
response = self.s.request(method, url, params=params, json=data, headers=headers)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
except Exception as e:
|
||||
print(f"请求错误: {e}")
|
||||
return None
|
||||
|
||||
def findByOpenIdAppId(self):
|
||||
Log(f"====== 获取TOKEN ======")
|
||||
try:
|
||||
params = {
|
||||
"appId":"wx52872495fb375c4b",
|
||||
"openId":self.openId,
|
||||
"source":"JD"
|
||||
}
|
||||
response = self.do_request('https://ump.ems.com.cn/memberCenterApiV2/member/findByOpenIdAppId',data=params)
|
||||
if response and response.get('code') == '000000':
|
||||
# print(response)
|
||||
info = response.get('info', {})
|
||||
self.token = info.get('token', '')
|
||||
self.memberId = info.get('memberId', '')
|
||||
self.headers['MC-TOKEN'] = self.token
|
||||
Log(f'>>获取token成功✅')
|
||||
# print(f'>用户ID:【{self.memberId}】')
|
||||
return True
|
||||
else:
|
||||
Log(f">获取TOKEN失败❌: {response}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"获取TOKEN异常❌: {e}")
|
||||
return False
|
||||
|
||||
def details(self):
|
||||
Log(f"====== 获取用户信息 ======")
|
||||
try:
|
||||
params = {}
|
||||
response = self.do_request('https://ump.ems.com.cn/memberCenterApiV2/member/details',data=params)
|
||||
if response and response.get('code') == '000000':
|
||||
# print(response)
|
||||
info = response.get('info', {})
|
||||
phone = info.get('phone', '')
|
||||
Log(f'>>获取用户信息成功✅')
|
||||
Log(f'>用户ID:【{self.memberId}】\n手机号:【{phone}】')
|
||||
return True
|
||||
else:
|
||||
Log(f">获取TOKEN失败❌: {response}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"获取TOKEN异常❌: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def sign(self):
|
||||
Log(f"====== 开始签到 ======")
|
||||
try:
|
||||
params = {
|
||||
"appId":"wx52872495fb375c4b",
|
||||
"userId":self.memberId,
|
||||
"openId":self.openId,
|
||||
"activId":'d191dce0740849b1b7377e83c00475d6'
|
||||
}
|
||||
response = self.do_request('https://ump.ems.com.cn/activCenterApi/signActivInfo/sign',data=params)
|
||||
if response and response.get('code') == '000000':
|
||||
# print(response)
|
||||
info = response.get('info', {})
|
||||
prizeSize = info.get('prizeSize', {})
|
||||
Log(f'>签到成功✅获得:【{prizeSize}】积分')
|
||||
return True
|
||||
elif response and response.get('code') == '600001':
|
||||
msg = response.get('msg')
|
||||
Log(f'>签到失败❌ 【{msg}】')
|
||||
else:
|
||||
Log(f"签到失败❌: {response}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"登录验证异常❌: {e}")
|
||||
return False
|
||||
|
||||
def memberGoldsInfo(self):
|
||||
Log(f"====== 获取积分信息 ======")
|
||||
try:
|
||||
params = {}
|
||||
response = self.do_request('https://ump.ems.com.cn/memberCenterApiV2/golds/memberGoldsInfo',data=params)
|
||||
if response and response.get('code') == '000000':
|
||||
# print(response)
|
||||
info = response.get('info', {})
|
||||
availableGoldsTotal = info.get('availableGoldsTotal', {})
|
||||
Log(f'>当前积分:【{availableGoldsTotal}】')
|
||||
return True
|
||||
else:
|
||||
Log(f"获取积分信息失败❌: {response}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"获取积分信息异常❌: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def main(self):
|
||||
Log(f"\n开始执行第{self.index}个账号--------------->>>>>")
|
||||
# if self.login():
|
||||
|
||||
if self.findByOpenIdAppId():
|
||||
self.details()
|
||||
self.sign()
|
||||
self.memberGoldsInfo()
|
||||
self.sendMsg()
|
||||
return True
|
||||
else:
|
||||
self.sendMsg()
|
||||
return False
|
||||
|
||||
def sendMsg(self):
|
||||
if self.send_UID:
|
||||
push_res = CHERWIN_TOOLS.wxpusher(self.send_UID, one_msg, APP_NAME)
|
||||
print(push_res)
|
||||
return True
|
||||
|
||||
|
||||
def down_file(filename, file_url):
|
||||
print(f'开始下载:{filename},下载地址:{file_url}')
|
||||
try:
|
||||
response = requests.get(file_url, verify=False, timeout=10)
|
||||
response.raise_for_status()
|
||||
with open(filename + '.tmp', 'wb') as f:
|
||||
f.write(response.content)
|
||||
print(f'【{filename}】下载完成!')
|
||||
|
||||
# 检查临时文件是否存在
|
||||
temp_filename = filename + '.tmp'
|
||||
if os.path.exists(temp_filename):
|
||||
# 删除原有文件
|
||||
if os.path.exists(filename):
|
||||
os.remove(filename)
|
||||
# 重命名临时文件
|
||||
os.rename(temp_filename, filename)
|
||||
print(f'【{filename}】重命名成功!')
|
||||
return True
|
||||
else:
|
||||
print(f'【{filename}】临时文件不存在!')
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f'【{filename}】下载失败:{str(e)}')
|
||||
return False
|
||||
|
||||
|
||||
def import_Tools():
|
||||
global CHERWIN_TOOLS, ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
|
||||
import CHERWIN_TOOLS
|
||||
ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode = CHERWIN_TOOLS.main(APP_NAME, local_script_name, ENV_NAME,
|
||||
local_version)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
APP_NAME = 'EMS邮惠中心小程序'
|
||||
ENV_NAME = 'EMS'
|
||||
CK_NAME = 'openId'
|
||||
CK_URL = 'https://ump.ems.com.cn/memberCenterApiV2/member/findByOpenIdAppId'
|
||||
print(f'''
|
||||
✨✨✨ {APP_NAME}签到✨✨✨
|
||||
✨ 功能:
|
||||
积分签到
|
||||
✨ 抓包步骤:
|
||||
打开{APP_NAME}
|
||||
授权登陆
|
||||
打开抓包工具
|
||||
找{CK_URL}请求body里面的[{CK_NAME}]
|
||||
复制里面的[{CK_NAME}]参数值
|
||||
参数示例:o-7675D-prmxxxxxxxxxx
|
||||
✨ ✨✨wxpusher一对一推送功能,
|
||||
✨需要定义变量export WXPUSHER=wxpusher的app_token,不设置则不启用wxpusher一对一推送
|
||||
✨需要在{ENV_NAME}变量最后添加@wxpusher的UID
|
||||
✨ 设置青龙变量:
|
||||
export {ENV_NAME}='{CK_NAME}参数值'多账号#或&分割
|
||||
export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨ ✨ 注意:抓完CK没事儿别打开小程序,重新打开小程序请重新抓包
|
||||
✨ 推荐cron:0 10 * * *
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
if not token:
|
||||
print(f"未填写{ENV_NAME}变量\n青龙可在环境变量设置 {ENV_NAME} 或者在本脚本文件上方将{CK_NAME}填入token =''")
|
||||
exit()
|
||||
tokens = CHERWIN_TOOLS.ENV_SPLIT(token)
|
||||
# print(tokens)
|
||||
if len(tokens) > 0:
|
||||
print(f"\n>>>>>>>>>>共获取到{len(tokens)}个账号<<<<<<<<<<")
|
||||
access_token = []
|
||||
for index, infos in enumerate(tokens):
|
||||
run_result = RUN(infos, index).main()
|
||||
if not run_result: continue
|
||||
if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|
||||
493
GJJJ.py
Executable file
493
GJJJ.py
Executable file
@ -0,0 +1,493 @@
|
||||
# !/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
# -------------------------------
|
||||
# ✨✨✨ @Author CHERWIN✨✨✨
|
||||
# -------------------------------
|
||||
# cron "1 9 * * *" script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('顾家家居小程序')
|
||||
import os
|
||||
import random
|
||||
import time
|
||||
|
||||
import requests
|
||||
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
else:
|
||||
print("加载通知服务失败!")
|
||||
send_msg = ''
|
||||
one_msg=''
|
||||
def Log(cont=''):
|
||||
global send_msg,one_msg
|
||||
print(cont)
|
||||
if cont:
|
||||
one_msg += f'{cont}\n'
|
||||
send_msg += f'{cont}\n'
|
||||
|
||||
class RUN:
|
||||
def __init__(self,info,index):
|
||||
global one_msg
|
||||
one_msg = ''
|
||||
split_info = info.split('@')
|
||||
|
||||
# self.token = json.loads(split_info[0])
|
||||
len_split_info = len(split_info)
|
||||
if len_split_info < 3:return False
|
||||
identityValue = split_info[0]
|
||||
openid = split_info[1]
|
||||
unionid = split_info[2]
|
||||
self.token = {
|
||||
"identityType":"mobile",
|
||||
"identityValue":identityValue,
|
||||
"type2":"wechat-unionid",
|
||||
"value2":"",
|
||||
"source":"顾家小程序",
|
||||
"contentName":"",
|
||||
"openid":openid,
|
||||
"unionid":unionid
|
||||
}
|
||||
# print(self.token)
|
||||
last_info = split_info[len_split_info - 1]
|
||||
self.send_UID = None
|
||||
if len_split_info > 0 and "UID_" in last_info:
|
||||
print('检测到设置了UID')
|
||||
print(last_info)
|
||||
self.send_UID = last_info
|
||||
self.index = index + 1
|
||||
self.max_try = 3
|
||||
self.headers = {
|
||||
"Host": "mc.kukahome.com",
|
||||
"E-Opera": "",
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090a13) XWEB/8555",
|
||||
"Content-Type": "application/json",
|
||||
# "timestamp": "1715180892075",
|
||||
"xweb_xhr": "1",
|
||||
"brandCode": "K001",
|
||||
# "X-Customer": "4802198",
|
||||
"appid": "667516",
|
||||
# "sign": "7acf4f02413bd9855047cc345be6da21",
|
||||
"Accept": "*/*",
|
||||
"Sec-Fetch-Site": "cross-site",
|
||||
"Sec-Fetch-Mode": "cors",
|
||||
"Sec-Fetch-Dest": "empty",
|
||||
"Referer": "https://servicewechat.com/wx0770280d160f09fe/179/page-frame.html",
|
||||
"Accept-Language": "zh-CN,zh;q=0.9",
|
||||
}
|
||||
|
||||
def generate_sign(self):
|
||||
new_data = CHERWIN_TOOLS.GJJJ_SIGN()
|
||||
self.headers.update(new_data)
|
||||
|
||||
|
||||
def make_request(self, url, method='post', headers={}, params={}):
|
||||
self.generate_sign()
|
||||
if headers == {}:
|
||||
headers = self.headers
|
||||
# if params == {}:
|
||||
# params = self.default_data
|
||||
try:
|
||||
if method.lower() == 'get':
|
||||
response = requests.get(url, headers=headers, verify=False)
|
||||
|
||||
elif method.lower() == 'post':
|
||||
response = requests.post(url, headers=headers, json=params, verify=False)
|
||||
else:
|
||||
raise ValueError("不支持的请求方法❌: " + method)
|
||||
return response.json()
|
||||
except requests.exceptions.RequestException as e:
|
||||
print("请求异常❌:", e)
|
||||
except ValueError as e:
|
||||
print("值错误或不支持的请求方法❌:", e)
|
||||
except Exception as e:
|
||||
print("发生了未知错误❌:", e)
|
||||
|
||||
def automaticLogin(self):
|
||||
Log('======= 刷新用户信息 =======')
|
||||
url = 'https://mc.kukahome.com/club-server/member/automaticLogin'
|
||||
response = self.make_request(url,params=self.token)
|
||||
# print(response)
|
||||
if response.get('msg')== "成功":
|
||||
data = response.get('data','')
|
||||
AccessToken = data.get('AccessToken','')
|
||||
membership = data.get('membership', {})
|
||||
point = membership.get('point', '')
|
||||
# systemSource = membership.get('systemSource', '')
|
||||
self.membershipId = membership.get('id', '')
|
||||
self.brandCode = membership.get('brandCode', '')
|
||||
self.mobile = membership.get('mobile', '')
|
||||
oneId = membership.get('oneId', '')
|
||||
memberLevel = membership.get('memberLevel', '')
|
||||
new_headers={
|
||||
"brandCode":self.brandCode,
|
||||
"X-Customer": str(self.membershipId),
|
||||
"AccessToken":AccessToken
|
||||
}
|
||||
self.headers.update(new_headers)
|
||||
Log(f'>手机号:【{self.mobile}】')
|
||||
print(f'>ID:【{self.membershipId}】')
|
||||
print(f'>等级:【{memberLevel}】')
|
||||
print(f'>oneId:【{oneId}】')
|
||||
Log(f'>当前积分:【{point}】')
|
||||
|
||||
return True
|
||||
else:
|
||||
Log(f'>可能token失效了❌,{response}')
|
||||
return False
|
||||
def personal(self):
|
||||
Log('======= 查询用户信息 =======')
|
||||
url = 'https://mc.kukahome.com/club-server/front/member/personal'
|
||||
response = self.make_request(url,params=self.token)
|
||||
# print(response)
|
||||
if response:
|
||||
point = response.get('point','')
|
||||
Log(f'>执行后积分:【{point}】')
|
||||
return True
|
||||
else:
|
||||
Log(f'>可能token失效了❌,{response}')
|
||||
return False
|
||||
|
||||
def selectPointTask(self):
|
||||
Log('======= 获取任务列表 =======')
|
||||
url = 'https://mc.kukahome.com/club-server/front/member/selectPointTask'
|
||||
data={"brandCode":self.brandCode}
|
||||
response = self.make_request(url,params=data)
|
||||
print(response)
|
||||
if response.get('code')== 0:
|
||||
data = response.get('data',[{}])
|
||||
for li in data:
|
||||
pass
|
||||
return True
|
||||
else:
|
||||
Log(f'>可能token失效了❌,{response}')
|
||||
return False
|
||||
|
||||
def checkSign(self):
|
||||
Log('======= 查询签到状态 =======')
|
||||
url = 'https://mc.kukahome.com/club-server/front/member/calendar'
|
||||
data={
|
||||
"t":int(time.time()*1000),
|
||||
"membershipId":self.membershipId
|
||||
}
|
||||
response = self.make_request(url,params=data)
|
||||
if response:
|
||||
isTodaySigned = response.get('isTodaySigned',False)
|
||||
if not isTodaySigned:
|
||||
Log('>今日未签到')
|
||||
self.signIn()
|
||||
else:
|
||||
Log('>今日已签到✅')
|
||||
return True
|
||||
else:
|
||||
Log(f'>可能token失效了❌,{response}')
|
||||
return False
|
||||
|
||||
def signIn(self):
|
||||
Log('======= 开始签到 =======')
|
||||
url = 'https://mc.kukahome.com/club-server/front/member/signIn'
|
||||
data={
|
||||
"identityType":"mobile",
|
||||
"identityValue":self.mobile,
|
||||
"membershipId":self.membershipId
|
||||
}
|
||||
response = self.make_request(url,params=data)
|
||||
# print(response)
|
||||
if response.get('status')== 200:
|
||||
data = response.get('data',[])
|
||||
success = data.get('success',False)
|
||||
if success:
|
||||
Log('>签到成功!✅')
|
||||
else:
|
||||
Log(f'>可能token失效了❌,{response}')
|
||||
return False
|
||||
|
||||
def selectPage(self):
|
||||
print('======= 获取帖子列表 =======')
|
||||
url = 'https://mc.kukahome.com/club-server/applet/waterfall/selectPage'
|
||||
random_topicId = str(random.randint(0,27))
|
||||
data={"source":1,"pageNum":1,"pageSize":5,"topicId":random_topicId}
|
||||
response = self.make_request(url,params=data)
|
||||
# print(response)
|
||||
if response.get('code')== 0:
|
||||
data = response.get('data',{})
|
||||
list = data.get('list',[{}])
|
||||
if list:
|
||||
print('>获取帖子列表成功✅')
|
||||
randomlist=random.choices(list)
|
||||
# print(randomlist)
|
||||
self.postLikeTask(randomlist)
|
||||
self.postCollectTask(randomlist)
|
||||
self.postCollectTask(randomlist)
|
||||
return True
|
||||
else:
|
||||
if self.max_try > 0:
|
||||
print('>获取帖子列表失败❌!正常重试....')
|
||||
self.selectPage()
|
||||
self.max_try -= 1
|
||||
else:
|
||||
Log(f'>可能token失效了❌,{response}')
|
||||
return False
|
||||
|
||||
def like_post(self, post_id):
|
||||
url = 'https://mc.kukahome.com/club-server/front/postOrder/like'
|
||||
data = {"id": post_id}
|
||||
response = self.make_request(url, params=data)
|
||||
return response
|
||||
|
||||
def likeSendPoint(self, post_id,triggerType,content):
|
||||
url = 'https://mc.kukahome.com/club-server/front/member/likeSendPoint'
|
||||
data = {
|
||||
"postOrderId": post_id,
|
||||
"triggerType": triggerType,
|
||||
"content": content
|
||||
}
|
||||
response = self.make_request(url, params=data)
|
||||
return response
|
||||
|
||||
|
||||
def collect_post(self, post_id):
|
||||
url = 'https://mc.kukahome.com/club-server/front/postOrder/collect'
|
||||
data = {"id": post_id}
|
||||
response = self.make_request(url, params=data)
|
||||
return response
|
||||
|
||||
|
||||
def submit_comment(self, post_id, content, post_member_id, parent_id="", is_flag=False):
|
||||
url = 'https://mc.kukahome.com/club-server/user/post/comment/insert'
|
||||
data = {
|
||||
"postId": post_id,
|
||||
"parentId": parent_id,
|
||||
"content": content,
|
||||
"postMemberId": post_member_id,
|
||||
"commentMemberId": self.access_token,
|
||||
"isFlag": is_flag
|
||||
}
|
||||
response = self.make_request(url, params=data)
|
||||
return response
|
||||
|
||||
def insert_foot_point(self, buried_point_logo, subordinate_terminal, business_name, business_code,current_page_link):
|
||||
url = 'https://mc.kukahome.com/club-server/front/foot/point/insertFootPoint'
|
||||
data = {
|
||||
"brandCode": "K001",
|
||||
"buriedPointLogo": buried_point_logo,
|
||||
"subordinateTerminal": subordinate_terminal,
|
||||
"businessName": business_name,
|
||||
"businessCode": business_code,
|
||||
"currentPageLink": current_page_link
|
||||
}
|
||||
response = self.make_request(url, params=data)
|
||||
return response
|
||||
|
||||
def push_event(self, event_id, content, target_id, target_name, business_id, business_name):
|
||||
url = 'https://mc.kukahome.com/club-server/front/member/pushEvent'
|
||||
data = {
|
||||
"eventId": event_id,
|
||||
"content": content,
|
||||
"targetId": target_id,
|
||||
"targetName": target_name,
|
||||
"businessId": business_id,
|
||||
"businessName": business_name
|
||||
}
|
||||
response = self.make_request(url, params=data)
|
||||
return response
|
||||
|
||||
def like_send_point(self, post_order_id, trigger_type, content):
|
||||
url = 'https://mc.kukahome.com/club-server/front/member/likeSendPoint'
|
||||
data = {
|
||||
"postOrderId": post_order_id,
|
||||
"triggerType": trigger_type,
|
||||
"content": content
|
||||
}
|
||||
response = self.make_request(url, params=data)
|
||||
return response
|
||||
|
||||
def resp_result(self,even,response):
|
||||
if response.get('message','') == '提示:保存成功!':
|
||||
print(f'{even}保存成功✅')
|
||||
else:
|
||||
print(f'{even}保存失败❌')
|
||||
|
||||
def postLikeTask(self,postlist):
|
||||
# 点赞帖子
|
||||
post_id = postlist[0]['id']
|
||||
title = postlist[0]['title']
|
||||
print("======= 进入点赞流程------>>>")
|
||||
# 推送点赞事件
|
||||
event_response = self.push_event(event_id="c_showhome_like", content="晒家-点赞", target_id="300001",target_name="晒家-点赞", business_id=post_id,business_name=title)
|
||||
|
||||
self.resp_result("推送点赞事件:", event_response)
|
||||
|
||||
# 点赞事件
|
||||
like_response = self.like_post(post_id)
|
||||
self.resp_result("点赞帖子:", like_response)
|
||||
|
||||
# 插入点赞足迹
|
||||
foot_point_response = self.insert_foot_point(buried_point_logo="do_good_btn",subordinate_terminal="会员小程序", business_name="",business_code="", current_page_link="")
|
||||
self.resp_result("插入点赞足迹:", foot_point_response)
|
||||
#
|
||||
# 点赞送积分
|
||||
like_point_response = self.like_send_point(post_order_id=post_id, trigger_type="1",content="点赞")
|
||||
self.resp_result("点赞送积分响应:", like_point_response)
|
||||
|
||||
print("------>>>点赞结束\n")
|
||||
print("======= 进入取消点赞流程------>>>")
|
||||
# 取消点赞帖子
|
||||
like_response = self.like_post(post_id)
|
||||
self.resp_result("取消点赞帖子:", like_response)
|
||||
|
||||
# 插入取消点赞足迹
|
||||
foot_point_response = self.insert_foot_point(buried_point_logo="cancel_good_btn", subordinate_terminal="会员小程序",business_name="", business_code="", current_page_link="")
|
||||
self.resp_result("插入取消点赞足迹:", foot_point_response)
|
||||
#
|
||||
# 推送取消点赞事件
|
||||
event_response = self.push_event(event_id="c_showhome_unlike", content="晒家-取消点赞", target_id="300002",target_name="晒家-取消点赞", business_id=post_id, business_name=title)
|
||||
self.resp_result("推送取消点赞事件:", event_response)
|
||||
print("------>>>取消点赞结束\n")
|
||||
|
||||
def postCollectTask(self,postlist):
|
||||
|
||||
post_id = postlist[0]['id']
|
||||
title = postlist[0]['title']
|
||||
|
||||
print("======= 进入收藏帖子流程------>>>")
|
||||
# 收藏帖子
|
||||
collect_response = self.collect_post(post_id)
|
||||
self.resp_result("收藏帖子:", collect_response)
|
||||
|
||||
# 插入收藏足迹
|
||||
foot_point_response = self.insert_foot_point(buried_point_logo="buriedPointLogo", subordinate_terminal="会员小程序", business_name="", business_code="", current_page_link="")
|
||||
self.resp_result("插入收藏足迹:", foot_point_response)
|
||||
#
|
||||
#收藏送积分
|
||||
likeSendPoint_response = self.likeSendPoint(post_id, 2, "收藏")
|
||||
self.resp_result("收藏送积分:", likeSendPoint_response)
|
||||
|
||||
print("------>>>收藏帖子结束\n")
|
||||
print("======= 进入取消收藏帖子流程------>>>")
|
||||
# 取消收藏足迹
|
||||
foot_point_response = self.insert_foot_point(buried_point_logo="cancel_collect_btn", subordinate_terminal="会员小程序",business_name="", business_code="", current_page_link="")
|
||||
self.resp_result("取消收藏足迹:", foot_point_response)
|
||||
|
||||
# 取消收藏帖子
|
||||
uncollect_response = self.collect_post(post_id)
|
||||
self.resp_result("取消收藏帖子:", uncollect_response)
|
||||
|
||||
print("------>>>取消收藏帖子结束\n")
|
||||
|
||||
def main(self):
|
||||
Log(f"\n======= 开始执行第{self.index}个账号 =======")
|
||||
if self.automaticLogin():
|
||||
self.checkSign()
|
||||
# self.selectPointTask()
|
||||
self.selectPage()
|
||||
self.personal()
|
||||
self.sendMsg()
|
||||
return True
|
||||
else:
|
||||
self.sendMsg()
|
||||
return False
|
||||
|
||||
def sendMsg(self):
|
||||
if self.send_UID:
|
||||
push_res = CHERWIN_TOOLS.wxpusher(self.send_UID, one_msg, APP_NAME)
|
||||
print(push_res)
|
||||
|
||||
|
||||
def down_file(filename, file_url):
|
||||
print(f'开始下载:{filename},下载地址:{file_url}')
|
||||
try:
|
||||
response = requests.get(file_url, verify=False, timeout=10)
|
||||
response.raise_for_status()
|
||||
with open(filename + '.tmp', 'wb') as f:
|
||||
f.write(response.content)
|
||||
print(f'【{filename}】下载完成!')
|
||||
|
||||
# 检查临时文件是否存在
|
||||
temp_filename = filename + '.tmp'
|
||||
if os.path.exists(temp_filename):
|
||||
# 删除原有文件
|
||||
if os.path.exists(filename):
|
||||
os.remove(filename)
|
||||
# 重命名临时文件
|
||||
os.rename(temp_filename, filename)
|
||||
print(f'【{filename}】重命名成功!')
|
||||
return True
|
||||
else:
|
||||
print(f'【{filename}】临时文件不存在!')
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f'【{filename}】下载失败:{str(e)}')
|
||||
return False
|
||||
|
||||
def import_Tools():
|
||||
global CHERWIN_TOOLS,ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
|
||||
import CHERWIN_TOOLS
|
||||
ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode = CHERWIN_TOOLS.main(APP_NAME, local_script_name, ENV_NAME,local_version)
|
||||
|
||||
if __name__ == '__main__':
|
||||
APP_NAME = '顾家家居小程序'
|
||||
ENV_NAME = 'GJJJ'
|
||||
CK_URL = 'https://mc.kukahome.com/club-server/member/automaticLogin'
|
||||
CK_NAME = 'identityValue@openid@o98mO0xrQ9Jqp0DUsGpmfHpQm_pQ'
|
||||
print(f'''
|
||||
✨✨✨ {APP_NAME}签到✨✨✨
|
||||
✨ 功能:
|
||||
积分签到
|
||||
社区互动
|
||||
✨ 抓包步骤:
|
||||
打开{APP_NAME}
|
||||
授权登陆
|
||||
打开抓包工具
|
||||
找{CK_URL}返回值[{CK_NAME}]
|
||||
参数示例:3ee9ceccccscscscscscscsc
|
||||
✨ ✨✨wxpusher一对一推送功能,
|
||||
✨需要定义变量export WXPUSHER=wxpusher的app_token,不设置则不启用wxpusher一对一推送
|
||||
✨需要在{ENV_NAME}变量最后添加@wxpusher的UID
|
||||
✨ 设置青龙变量:
|
||||
export {ENV_NAME}='{CK_NAME}参数值'多账号#或&分割
|
||||
export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨ ✨ 注意:抓完CK没事儿别打开小程序,重新打开小程序请重新抓包
|
||||
✨ 推荐cron:1 9 * * *
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.05.09'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
if not token:
|
||||
print(f"未填写{ENV_NAME}变量\n青龙可在环境变量设置 {ENV_NAME} 或者在本脚本文件上方将{CK_NAME}填入token =''")
|
||||
exit()
|
||||
tokens = CHERWIN_TOOLS.ENV_SPLIT(token)
|
||||
# print(tokens)
|
||||
if len(tokens) > 0:
|
||||
print(f"\n>>>>>>>>>>共获取到{len(tokens)}个账号<<<<<<<<<<")
|
||||
access_token = []
|
||||
for index, infos in enumerate(tokens):
|
||||
s = requests.session()
|
||||
s.verify = False
|
||||
run_result = RUN(infos, index).main()
|
||||
if not run_result: continue
|
||||
if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|
||||
26
HDL.py
26
HDL.py
@ -1,10 +1,11 @@
|
||||
# !/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
# -------------------------------
|
||||
# ✨ 推荐cron:0 6 * * *
|
||||
# ✨✨✨ @Author CHERWIN✨✨✨
|
||||
# -------------------------------
|
||||
# cron "1 8 * * *" script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('海底捞小程序签到')
|
||||
# cron "0 6 * * *" script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('中通快递小程序签到')
|
||||
|
||||
import os
|
||||
from os import path
|
||||
@ -15,8 +16,11 @@ from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
@ -237,6 +241,7 @@ class RUN:
|
||||
self.sendMsg()
|
||||
return True
|
||||
else:
|
||||
self.sendMsg()
|
||||
return False
|
||||
def sendMsg(self):
|
||||
if self.send_UID:
|
||||
@ -299,20 +304,23 @@ if __name__ == '__main__':
|
||||
export {ENV_NAME}='{CK_NAME}参数值'多账号#或&分割
|
||||
export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨ ✨ 注意:抓完CK没事儿别打开小程序,重新打开小程序请重新抓包
|
||||
✨ 推荐cron:01 8 * * *
|
||||
✨ 推荐cron:0 6 * * *
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.04.08'
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://py.cherwin.cn/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://py.cherwin.cn/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
|
||||
24
JTSD.py
24
JTSD.py
@ -1,9 +1,8 @@
|
||||
# !/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
# -------------------------------
|
||||
# ✨✨✨ @Author CHERWIN✨✨✨
|
||||
# -------------------------------
|
||||
# cron "0 6 * * *" script-path=xxx.py,tag=匹配cron用
|
||||
# cron "0 5 * * *" script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('极兔速递小程序签到')
|
||||
import json
|
||||
import os
|
||||
@ -17,8 +16,11 @@ from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
@ -133,6 +135,7 @@ class RUN:
|
||||
self.sign()
|
||||
self.sendMsg()
|
||||
else:
|
||||
self.sendMsg()
|
||||
return False
|
||||
|
||||
def sendMsg(self):
|
||||
@ -200,16 +203,19 @@ export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.04.18'
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://py.cherwin.cn/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://py.cherwin.cn/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
@ -224,4 +230,4 @@ export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
for index, infos in enumerate(tokens):
|
||||
run_result = RUN(infos, index).main()
|
||||
if not run_result: continue
|
||||
if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|
||||
if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|
||||
115
KFHS.py
115
KFHS.py
@ -1,21 +1,23 @@
|
||||
# !/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
# -------------------------------
|
||||
# cron "30 1 * * *" script-path=xxx.py,tag=匹配cron用
|
||||
# cron "0 0,8 * * " script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('微信公众号:卡夫亨氏新厨艺')
|
||||
|
||||
import os
|
||||
import random
|
||||
import time
|
||||
from datetime import date, datetime
|
||||
from datetime import date, datetime,time as times
|
||||
|
||||
import requests
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# import CHERWIN_TOOLS
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
@ -75,7 +77,7 @@ class RUN:
|
||||
openId = data.get('openId','')
|
||||
signTimes = data.get('signTimes',0)
|
||||
memberInfo = data.get('memberInfo', {})
|
||||
phone = memberInfo.get('phone', '')
|
||||
self.phone = memberInfo.get('phone', '')
|
||||
score = memberInfo.get('score', '')
|
||||
if End :
|
||||
Log(f'执行后积分:【{score}】')
|
||||
@ -84,22 +86,23 @@ class RUN:
|
||||
# add = {"nickname":nickname,"member_id":member_id}
|
||||
userid_list.append(self.member_id)
|
||||
username_list.append(nickname)
|
||||
Log(f'>>>当前用户:【{nickname}】\nID:【{self.member_id}】 \nOpenID:【{openId}】 \n已连续签到【{signTimes}】天')
|
||||
serialSign = data.get('serialSign', [{}])
|
||||
signTimes = data.get('signTimes', 0)
|
||||
Log(f'>>>当前用户:【{nickname}】\nID:【{self.member_id}】 \nOpenID:【{openId}】 \n已连续签到【{signTimes}】天')
|
||||
|
||||
if serialSign :
|
||||
if serialSign:
|
||||
current_date = date.today()
|
||||
date_string = serialSign[0].get('createdAt',current_date)
|
||||
memberBalance = serialSign[0].get('memberBalance', 0)
|
||||
parsed_date = datetime.strptime(date_string, '%Y-%m-%d %H:%M:%S').date()
|
||||
if parsed_date == current_date:
|
||||
print(f"今日已签到,当前积分:【{memberBalance}】")
|
||||
else:
|
||||
print("今日未签到")
|
||||
wait_time = random.randint(1000, 10000) / 1000.0 # 转换为秒
|
||||
time.sleep(wait_time)
|
||||
print('随机延时1-10秒执行签到')
|
||||
self.dailySign()
|
||||
else:
|
||||
print("今日未签到")
|
||||
wait_time = random.randint(1000, 10000) / 1000.0 # 转换为秒
|
||||
time.sleep(wait_time)
|
||||
print('随机延时1-10秒执行签到')
|
||||
self.dailySign()
|
||||
return True
|
||||
except:
|
||||
print(response.text)
|
||||
@ -141,12 +144,33 @@ class RUN:
|
||||
id_list = resp['data']['chineseCookbook']['data']
|
||||
for i in id_list:
|
||||
Cookid_list.append(i['id'])
|
||||
# self.creatCookbookCode(i['id'])
|
||||
print(f'>获取到菜谱ID:【{Cookid_list}】')
|
||||
except:
|
||||
print(response.text)
|
||||
else:
|
||||
print("API访问失败!")
|
||||
|
||||
def creatCookbookCode(self,cookbook_id):
|
||||
|
||||
data = {
|
||||
'cookbook_id':cookbook_id
|
||||
}
|
||||
response = self.s.post(
|
||||
f'{self.baseUrl}createCookbookCode',
|
||||
headers=self.headers, data=data
|
||||
)
|
||||
if response.status_code == 200:
|
||||
try:
|
||||
resp = response.json()
|
||||
data = resp.get('data',{})
|
||||
code_url = data.get('code_url','')
|
||||
print(f'创建分享链接成功:[{code_url}]')
|
||||
except:
|
||||
print(response.text)
|
||||
else:
|
||||
print("API访问失败!")
|
||||
|
||||
def recordScoreShare(self, cookbook_id, now_id):
|
||||
# print('')
|
||||
# self.getUserInfo()
|
||||
@ -195,19 +219,31 @@ class RUN:
|
||||
else:
|
||||
Log('助力对象为自身,跳过')
|
||||
|
||||
# 预留兑换函数
|
||||
def exchangeIntegralNew(self):
|
||||
def exchange(self):
|
||||
data = {
|
||||
'value': '爱奇艺月卡',
|
||||
'phone': '',
|
||||
'type': '视频卡'
|
||||
'phone': self.phone
|
||||
}
|
||||
# data = {
|
||||
# 'value': '全网10元话费',
|
||||
# 'phone': '',
|
||||
# 'type': '话费',
|
||||
# 'memberId': '',
|
||||
# }
|
||||
huafei_li = ['全网10元话费', '全网20元话费']
|
||||
videoCard_li = ['爱奇艺', '腾讯', '优酷']
|
||||
cardType = ['年卡', '季卡', '月卡', '周卡']
|
||||
for card in huafei_li:
|
||||
data['value'] = card
|
||||
data['type'] = '话费'
|
||||
data['memberId'] = self.member_id
|
||||
self.exchangeIntegralNew(data)
|
||||
|
||||
for card in cardType:
|
||||
for video in videoCard_li:
|
||||
cardname = video + card
|
||||
data['value'] = cardname
|
||||
data['type'] = '视频卡'
|
||||
self.exchangeIntegralNew(data)
|
||||
print(cardname)
|
||||
|
||||
|
||||
# 预留兑换函数
|
||||
def exchangeIntegralNew(self,data):
|
||||
print(f'正在尝试兑换【{data["value"]}】')
|
||||
response = self.s.post(
|
||||
f'{self.baseUrl}exchangeIntegralNew',
|
||||
headers=self.headers,
|
||||
@ -224,15 +260,18 @@ class RUN:
|
||||
print("API访问失败!")
|
||||
|
||||
def main(self):
|
||||
# self.getUserInfo()
|
||||
# self.getCookbookIndex()
|
||||
if self.getUserInfo():
|
||||
if self.index == 1:
|
||||
self.getCookbookIndex()
|
||||
now = datetime.now().time()
|
||||
start_time = times(23, 59, 59)
|
||||
end_time = times(0, 5)
|
||||
if start_time <= now <= end_time:
|
||||
self.exchange()
|
||||
self.getCookbookIndex()
|
||||
self.getUserInfo(True)
|
||||
self.sendMsg()
|
||||
return True
|
||||
else:
|
||||
self.sendMsg()
|
||||
return False
|
||||
|
||||
def help(self):
|
||||
@ -245,6 +284,7 @@ class RUN:
|
||||
now_id = userid_list[self.index-1]
|
||||
Log(f'\n当前用于助力用户:【{username}】 ID:【{now_id}】')
|
||||
self.helpAuthor(662056, cookbook_id, now_id)
|
||||
self.helpAuthor(662086, cookbook_id, now_id)
|
||||
self.recordScoreShare(cookbook_id, now_id)
|
||||
self.sendMsg(True)
|
||||
return True
|
||||
@ -316,29 +356,32 @@ if __name__ == '__main__':
|
||||
export {ENV_NAME}='{CK_NAME}参数值'多账号#或&分割
|
||||
export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨ ✨ 注意:token有效期7天,7天后重新抓
|
||||
✨ 推荐cron:5 8 * * *
|
||||
✨ 推荐cron:0 0,8 * *
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.04.06'
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://py.cherwin.cn/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://py.cherwin.cn/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
print(token)
|
||||
# print(token)
|
||||
if not token:
|
||||
print(f"未填写{ENV_NAME}变量\n青龙可在环境变量设置 {ENV_NAME} 或者在本脚本文件上方将{CK_NAME}填入token =''")
|
||||
exit()
|
||||
tokens = CHERWIN_TOOLS.ENV_SPLIT(token)
|
||||
print(tokens)
|
||||
# print(tokens)
|
||||
Cookid_list = []
|
||||
userid_list = []
|
||||
username_list = []
|
||||
|
||||
372
KGZJ.py
Executable file
372
KGZJ.py
Executable file
@ -0,0 +1,372 @@
|
||||
# !/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
# -------------------------------
|
||||
# cron "30 9 * * *" script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('宽哥之家小程序')
|
||||
|
||||
import os
|
||||
import random
|
||||
import time
|
||||
|
||||
import requests
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# import CHERWIN_TOOLS
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
else:
|
||||
print("加载通知服务失败!")
|
||||
send_msg = ''
|
||||
one_msg=''
|
||||
def Log(cont=''):
|
||||
global send_msg,one_msg
|
||||
print(cont)
|
||||
if cont:
|
||||
one_msg += f'{cont}\n'
|
||||
send_msg += f'{cont}\n'
|
||||
|
||||
class RUN:
|
||||
def __init__(self,info,index):
|
||||
global one_msg
|
||||
one_msg = ''
|
||||
split_info = info.split('@')
|
||||
self.token = split_info[0]
|
||||
len_split_info = len(split_info)
|
||||
last_info = split_info[len_split_info - 1]
|
||||
self.send_UID = None
|
||||
if len_split_info > 0 and "UID_" in last_info:
|
||||
self.send_UID = last_info
|
||||
self.index = index + 1
|
||||
Log(f"\n---------开始执行第{self.index}个账号>>>>>")
|
||||
self.s = requests.session()
|
||||
self.s.verify = False
|
||||
|
||||
self.headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090a13) XWEB/9129',
|
||||
'Host': 'shop.sctobacco.com',
|
||||
'Connection': 'keep-alive',
|
||||
'xweb_xhr': '1',
|
||||
'gray': '0',
|
||||
'token': self.token,
|
||||
'Accept': '*/*',
|
||||
'Sec-Fetch-Site': 'cross-site',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Referer': 'https://servicewechat.com/wxb6bc0796e0f0db00/224/page-frame.html',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9'
|
||||
}
|
||||
self.s.headers.update(self.headers)
|
||||
|
||||
|
||||
def do_request(self, url, method='POST',params=None, data=None, headers=None):
|
||||
|
||||
try:
|
||||
response = self.s.request(method, url, params=params, json=data, headers=headers)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
except Exception as e:
|
||||
print(f"请求错误: {e}")
|
||||
return None
|
||||
|
||||
def personal_info(self):
|
||||
Log(f'======= 查询用户信息 =======')
|
||||
personal_info_valid = False
|
||||
try:
|
||||
# 发送GET请求
|
||||
response = self.do_request('https://shop.sctobacco.com/api/mc-server/mypage/simpleInfo',method='GET')
|
||||
# 检查请求是否成功
|
||||
if response.get('code','-1'):
|
||||
personal_info_valid = True
|
||||
data = response.get('data', {})
|
||||
mobile_phone = data.get('phone','')
|
||||
self.name = data.get('nickname','')
|
||||
unionId = data.get('unionId','')
|
||||
self.mobile_phone = mobile_phone[:3] + "*" * 4 + mobile_phone[7:]
|
||||
# 提取个人信息
|
||||
Log(f">>账号[{self.index}]登陆成功!✅\n用户名:【{self.name}】 \n手机号:【{self.mobile_phone}】")
|
||||
else:
|
||||
# 如果请求不成功,则打印错误信息
|
||||
message = response.get('msg', '')
|
||||
Log(f'>>登录失败❌: {message}')
|
||||
|
||||
except Exception as e:
|
||||
# 捕获任何异常并打印
|
||||
print(e)
|
||||
|
||||
finally:
|
||||
# 最终返回请求是否成功的标志
|
||||
return personal_info_valid
|
||||
|
||||
def myTask(self):
|
||||
print(f'======= 查询任务列表 =======')
|
||||
try:
|
||||
|
||||
# 发送GET请求
|
||||
response = self.do_request('https://shop.sctobacco.com/api/mc-server/mcTask/myTask',method='GET')
|
||||
# 检查请求是否成功
|
||||
if response.get('code','-1'):
|
||||
data = response.get('data', {})
|
||||
taskList = data.get('taskList',[{}])
|
||||
skip_task =[50001,50002,30002]
|
||||
for task in taskList:
|
||||
taskName = task.get('taskName', '')
|
||||
taskId = task.get('taskId', '')
|
||||
isCompleted = task.get('isCompleted', '0')
|
||||
print(f'>>当前任务:【{taskName}】')
|
||||
if taskId in skip_task:
|
||||
print('>暂不支持,跳过❌')
|
||||
continue
|
||||
if isCompleted != '0' :
|
||||
print('>已完成,跳过✅')
|
||||
continue
|
||||
if taskId == 30016:
|
||||
self.SignSubmit()
|
||||
elif taskId == 30004:
|
||||
self.listForMobile()
|
||||
else:
|
||||
# 如果请求不成功,则打印错误信息
|
||||
message = response.get('msg', '')
|
||||
Log(f'查询任务列表失败❌: {message}')
|
||||
|
||||
except Exception as e:
|
||||
# 捕获任何异常并打印
|
||||
print(e)
|
||||
|
||||
def get_score(self):
|
||||
Log(f'======= 获取积分信息 =======')
|
||||
try:
|
||||
timestamp = int(time.time() * 1000)
|
||||
# 发送GET请求
|
||||
response = self.do_request(f'https://shop.sctobacco.com/api/sc-server/log/detail?scoreTypeId=jifen001',method='GET')
|
||||
# 检查请求是否成功
|
||||
if response.get('code','-1'):
|
||||
data = response.get('data', {})
|
||||
if data:
|
||||
scoreTypeName = data.get('scoreTypeName', '')
|
||||
totalScore = data.get('totalScore', '')
|
||||
Log(f'>当前{scoreTypeName}:【{totalScore}】✅')
|
||||
else:
|
||||
Log('>获取积分信息失败❌')
|
||||
else:
|
||||
# 如果请求不成功,则打印错误信息
|
||||
message = response.get('msg', '')
|
||||
Log(f'获取积分信息失败❌: {message}')
|
||||
|
||||
except Exception as e:
|
||||
# 捕获任何异常并打印
|
||||
print(e)
|
||||
|
||||
def SignSubmit(self):
|
||||
Log(f'======= 签到 =======')
|
||||
try:
|
||||
timestamp = int(time.time() * 1000)
|
||||
# 发送GET请求
|
||||
response = self.do_request(f'https://shop.sctobacco.com/api/ac-server/manage/acSignMemberLog/SignSubmit?t={timestamp}',method='GET')
|
||||
# 检查请求是否成功
|
||||
if response.get('code','-1'):
|
||||
data = response.get('data', '')
|
||||
if data:
|
||||
Log(f'>签到成功✅,获得{data}积分')
|
||||
else:
|
||||
Log('>签到失败❌')
|
||||
else:
|
||||
# 如果请求不成功,则打印错误信息
|
||||
message = response.get('msg', '')
|
||||
Log(f'签到失败❌: {message}')
|
||||
|
||||
except Exception as e:
|
||||
# 捕获任何异常并打印
|
||||
print(e)
|
||||
|
||||
|
||||
def listForMobile(self):
|
||||
Log(f'======= 获取文章列表 =======')
|
||||
try:
|
||||
timestamp = int(time.time() * 1000)
|
||||
# 发送GET请求
|
||||
response = self.do_request(f'https://shop.sctobacco.com/api/mc-server/mcMedia/listForMobile?t={timestamp}&offset=0&limit=10&isShow=1',method='GET')
|
||||
# 检查请求是否成功
|
||||
if response.get('code','-1'):
|
||||
data = response.get('data', {})
|
||||
rows = response.get('rows', [{}])
|
||||
random_element = random.choice(rows)
|
||||
if random_element:
|
||||
Log(f'>>>获取文章列表成功✅')
|
||||
appid = random_element['appid']
|
||||
title = random_element['title']
|
||||
mediaId = random_element['mediaId']
|
||||
Log(f'>>前选择文章:【{title}】 appid:{appid} mediaId:{mediaId}')
|
||||
self.clickMedia(mediaId,appid)
|
||||
else:
|
||||
Log('>>获取文章列表失败❌')
|
||||
else:
|
||||
# 如果请求不成功,则打印错误信息
|
||||
message = response.get('msg', '')
|
||||
Log(f'获取文章列表失败❌: {message}')
|
||||
|
||||
except Exception as e:
|
||||
# 捕获任何异常并打印
|
||||
print(e)
|
||||
|
||||
def clickMedia(self,mediaId,appid):
|
||||
Log(f'======= 阅读文章 =======')
|
||||
try:
|
||||
parmas={
|
||||
'mpMediaId':mediaId,
|
||||
'mediaId':mediaId,
|
||||
'appid' :appid
|
||||
}
|
||||
# 发送GET请求
|
||||
response = self.do_request(f'https://shop.sctobacco.com/api/mc-server/mcMedia/clickMedia',method='GET',params=parmas)
|
||||
# 检查请求是否成功
|
||||
if response.get('code','-1'):
|
||||
message = response.get('message', {})
|
||||
if message == "success":
|
||||
Log(f'>阅读文章成功✅')
|
||||
else:
|
||||
Log('>阅读文章失败❌')
|
||||
else:
|
||||
# 如果请求不成功,则打印错误信息
|
||||
message = response.get('msg', '')
|
||||
Log(f'阅读文章❌: {message}')
|
||||
|
||||
except Exception as e:
|
||||
# 捕获任何异常并打印
|
||||
print(e)
|
||||
|
||||
def clickMedia(self,mediaId,appid):
|
||||
Log(f'======= 阅读文章 =======')
|
||||
try:
|
||||
parmas={
|
||||
'mpMediaId':mediaId,
|
||||
'mediaId':mediaId,
|
||||
'appid' :appid
|
||||
}
|
||||
# 发送GET请求
|
||||
response = self.do_request(f'https://shop.sctobacco.com/api/mc-server/mcMedia/clickMedia',method='GET',params=parmas)
|
||||
# 检查请求是否成功
|
||||
if response.get('code','-1'):
|
||||
message = response.get('message', {})
|
||||
if message == "success":
|
||||
Log(f'>阅读文章成功✅')
|
||||
else:
|
||||
Log('>阅读文章失败❌')
|
||||
else:
|
||||
# 如果请求不成功,则打印错误信息
|
||||
message = response.get('msg', '')
|
||||
Log(f'阅读文章❌: {message}')
|
||||
|
||||
except Exception as e:
|
||||
# 捕获任何异常并打印
|
||||
print(e)
|
||||
|
||||
|
||||
def main(self):
|
||||
if not self.personal_info() :
|
||||
Log("用户信息无效,请更新CK")
|
||||
self.sendMsg()
|
||||
return False
|
||||
self.myTask()
|
||||
self.get_score()
|
||||
self.sendMsg()
|
||||
return True
|
||||
|
||||
def sendMsg(self, help=False):
|
||||
if self.send_UID:
|
||||
push_res = CHERWIN_TOOLS.wxpusher(self.send_UID, one_msg, APP_NAME, help)
|
||||
print(push_res)
|
||||
|
||||
|
||||
def down_file(filename, file_url):
|
||||
print(f'开始下载:{filename},下载地址:{file_url}')
|
||||
try:
|
||||
response = requests.get(file_url, verify=False, timeout=10)
|
||||
response.raise_for_status()
|
||||
with open(filename + '.tmp', 'wb') as f:
|
||||
f.write(response.content)
|
||||
print(f'【{filename}】下载完成!')
|
||||
|
||||
# 检查临时文件是否存在
|
||||
temp_filename = filename + '.tmp'
|
||||
if os.path.exists(temp_filename):
|
||||
# 删除原有文件
|
||||
if os.path.exists(filename):
|
||||
os.remove(filename)
|
||||
# 重命名临时文件
|
||||
os.rename(temp_filename, filename)
|
||||
print(f'【{filename}】重命名成功!')
|
||||
return True
|
||||
else:
|
||||
print(f'【{filename}】临时文件不存在!')
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f'【{filename}】下载失败:{str(e)}')
|
||||
return False
|
||||
|
||||
def import_Tools():
|
||||
global CHERWIN_TOOLS,ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
|
||||
import CHERWIN_TOOLS
|
||||
ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode = CHERWIN_TOOLS.main(APP_NAME, local_script_name, ENV_NAME,local_version)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
APP_NAME = '宽哥之家小程序'
|
||||
ENV_NAME = 'KGZJ'
|
||||
CK_NAME = 'token'
|
||||
print(f'''
|
||||
✨✨✨ {APP_NAME}签到✨✨✨
|
||||
✨ 功能:
|
||||
积分签到
|
||||
✨ 抓包步骤:
|
||||
打开{APP_NAME}
|
||||
授权登陆
|
||||
打开抓包工具
|
||||
找请求头带{CK_NAME}的URl
|
||||
复制里面的{CK_NAME}参数值
|
||||
✨ ✨✨wxpusher一对一推送功能,
|
||||
✨需要定义变量export WXPUSHER=wxpusher的app_token,不设置则不启用wxpusher一对一推送
|
||||
✨需要在{ENV_NAME}变量最后添加@wxpusher的UID
|
||||
参数示例:1790314xxxxxx@UID_xxxxx
|
||||
✨ 设置青龙变量:
|
||||
export {ENV_NAME}='{CK_NAME}参数值'多账号#或&分割
|
||||
export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨ ✨ 注意:抓完CK没事儿别打开小程序,重新打开小程序请重新抓包
|
||||
✨ 推荐cron:5 8 * * *
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
if not token:
|
||||
print(f"未填写{ENV_NAME}变量\n青龙可在环境变量设置 {ENV_NAME} 或者在本脚本文件上方将{CK_NAME}填入token =''")
|
||||
exit()
|
||||
tokens = CHERWIN_TOOLS.ENV_SPLIT(token)
|
||||
# print(tokens)
|
||||
if len(tokens) > 0:
|
||||
print(f"\n>>>>>>>>>>共获取到{len(tokens)}个账号<<<<<<<<<<")
|
||||
for index, infos in enumerate(tokens):
|
||||
run_result = RUN(infos, index).main()
|
||||
if not run_result: continue
|
||||
if send: send(f'{APP_NAME}挂机通知', f'{send_msg}\n{TIPS_HTML}')
|
||||
18
KKYP.py
Normal file → Executable file
18
KKYP.py
Normal file → Executable file
@ -10,8 +10,11 @@ import requests
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
@ -159,16 +162,19 @@ export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.05.04'
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://py.cherwin.cn/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://py.cherwin.cn/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
|
||||
21
LSXDS.py
Normal file → Executable file
21
LSXDS.py
Normal file → Executable file
@ -14,9 +14,11 @@ from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# import CHERWIN_TOOLS
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
#
|
||||
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
@ -368,16 +370,19 @@ export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.05.08'
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://py.cherwin.cn/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://py.cherwin.cn/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
@ -394,4 +399,4 @@ export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
s.verify = False
|
||||
run_result = RUN(infos, index).main()
|
||||
if not run_result: continue
|
||||
if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|
||||
if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|
||||
18
MXBC.py
Normal file → Executable file
18
MXBC.py
Normal file → Executable file
@ -20,8 +20,11 @@ from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
@ -300,16 +303,19 @@ export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.04.15'
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://py.cherwin.cn/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://py.cherwin.cn/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
|
||||
676
NXDD.py
676
NXDD.py
@ -1,335 +1,341 @@
|
||||
# !/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
# -------------------------------
|
||||
# @Author CHERWIN✨✨✨
|
||||
# -------------------------------
|
||||
# cron "30 1 * * *" script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('奈雪小程序签到')
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import requests
|
||||
import hashlib
|
||||
import hmac
|
||||
import base64
|
||||
import time
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
else:
|
||||
print("加载通知服务失败!")
|
||||
send_msg = ''
|
||||
one_msg=''
|
||||
def Log(cont=''):
|
||||
global send_msg,one_msg
|
||||
print(cont)
|
||||
if cont:
|
||||
one_msg += f'{cont}\n'
|
||||
send_msg += f'{cont}\n'
|
||||
|
||||
class RUN:
|
||||
def __init__(self,info,index):
|
||||
global one_msg
|
||||
one_msg = ''
|
||||
split_info = info.split('@')
|
||||
token = split_info[0]
|
||||
len_split_info = len(split_info)
|
||||
last_info = split_info[len_split_info - 1]
|
||||
self.send_UID = None
|
||||
if len_split_info > 0 and "UID_" in last_info:
|
||||
print('检测到设置了UID')
|
||||
print(last_info)
|
||||
self.send_UID = last_info
|
||||
self.index = index + 1
|
||||
self.s = requests.session()
|
||||
self.s.verify = False
|
||||
|
||||
self.token = f'Bearer {token}'
|
||||
self.UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF XWEB/6945'
|
||||
self.openId = 'QL6ZOftGzbziPlZwfiXM'
|
||||
|
||||
def random_string(self,length=6, chars='123456789'):
|
||||
return ''.join(random.choice(chars) for _ in range(length))
|
||||
|
||||
def get_body(self):
|
||||
nonce = int(self.random_string())
|
||||
timestamp = int(time.time())
|
||||
url_path = f'nonce={nonce}&openId={self.openId}×tamp={timestamp}'
|
||||
signature = base64.b64encode(
|
||||
hmac.new('sArMTldQ9tqU19XIRDMWz7BO5WaeBnrezA'.encode(), url_path.encode(), hashlib.sha1).digest()).decode()
|
||||
common = {
|
||||
'platform': 'wxapp',
|
||||
'version': '5.1.8',
|
||||
'imei': '',
|
||||
'osn': 'microsoft',
|
||||
'sv': 'Windows 10 x64',
|
||||
'lang': 'zh_CN',
|
||||
'currency': 'CNY',
|
||||
'timeZone': '',
|
||||
'nonce': nonce,
|
||||
'openId': self.openId,
|
||||
'timestamp': timestamp,
|
||||
'signature': signature
|
||||
}
|
||||
params = {
|
||||
'businessType': 1,
|
||||
'brand': 26000252,
|
||||
'tenantId': 1,
|
||||
'channel': 2,
|
||||
'stallType': None,
|
||||
'storeId': None
|
||||
}
|
||||
|
||||
requestData = {
|
||||
'common': common,
|
||||
'params': params
|
||||
}
|
||||
return requestData
|
||||
|
||||
def task_api(self,api_options=None):
|
||||
if api_options is None:
|
||||
api_options = {}
|
||||
try:
|
||||
# 首先解析URL,获得主机名
|
||||
host_name = api_options['url'].replace('//', '/').split('/')[1]
|
||||
full_url = api_options['url']
|
||||
if 'queryParam' in api_options:
|
||||
# 如果存在查询参数,将其附加到URL
|
||||
query_str = "&".join(f"{k}={v}" for k, v in api_options['queryParam'].items())
|
||||
full_url += '?' + query_str
|
||||
# 定义请求头
|
||||
headers = {
|
||||
'Host': host_name,
|
||||
'Connection': 'keep-alive',
|
||||
'User-Agent': self.UA,
|
||||
'Authorization': self.token,
|
||||
'Referer': 'https://tm-web.pin-dao.cn/',
|
||||
'Origin': 'https://tm-web.pin-dao.cn'
|
||||
}
|
||||
# 准备请求体
|
||||
data = None
|
||||
if 'body' in api_options:
|
||||
body = self.get_body()
|
||||
body['params'].update(api_options['body'])
|
||||
content_type = api_options.get('Content-Type', 'application/json')
|
||||
headers['Content-Type'] = content_type
|
||||
if 'json' in content_type:
|
||||
data = json.dumps(body)
|
||||
else:
|
||||
data = "&".join(f"{k}={json.dumps(v) if isinstance(v, dict) else v}" for k, v in body.items())
|
||||
headers['Content-Length'] = str(len(data))
|
||||
# 如果有额外的URL参数或头部参数,合并到请求中
|
||||
if 'urlObjectParam' in api_options:
|
||||
# 这里根据需要处理urlObjectParam
|
||||
pass
|
||||
if 'headerParam' in api_options:
|
||||
headers.update(api_options['headerParam'])
|
||||
# 发出请求
|
||||
response = requests.request(method=api_options.get('method', 'GET'), url=full_url, headers=headers,
|
||||
data=data, timeout=20,verify=False)
|
||||
# 打印状态码
|
||||
if response.status_code != 200:
|
||||
print(f"[{api_options.get('fn', 'unknown function')}]返回[{response.status_code}]")
|
||||
|
||||
# 解析结果
|
||||
try:
|
||||
result = response.json()
|
||||
except ValueError:
|
||||
result = response.text
|
||||
return result
|
||||
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
return {}
|
||||
|
||||
def base_userinfo(self):
|
||||
try:
|
||||
api_options = {
|
||||
'fn': 'baseUserinfo',
|
||||
'method': 'post',
|
||||
'url': 'https://tm-web.pin-dao.cn/user/base-userinfo',
|
||||
'body': {}
|
||||
}
|
||||
response = self.task_api(api_options)
|
||||
if response['code'] == 0:
|
||||
# 登录成功的逻辑处理
|
||||
phone = response['data']['phone']
|
||||
self.phone = phone[:3] + "*" * 4 + phone[7:]
|
||||
self.userId = response['data']['userId']
|
||||
self.nickName = response['data']['nickName']
|
||||
Log(f'账号[{self.index}]登录成功!\n手机号:[{self.phone}] ID[{self.userId}]')
|
||||
# print(one_msg)
|
||||
return True
|
||||
else:
|
||||
# 登录失败的逻辑处理
|
||||
Log(f"账号登录失败: {response['message']}")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def user_account(self):
|
||||
try:
|
||||
api_options = {
|
||||
'fn': 'userAccount',
|
||||
'method': 'post',
|
||||
'url': 'https://tm-web.pin-dao.cn/user/account/user-account',
|
||||
'body': {}
|
||||
}
|
||||
response = self.task_api(api_options)
|
||||
if response['code'] == 0:
|
||||
# 查询成功的逻辑处理
|
||||
coin = response['data']['coin']
|
||||
Log(f'账号[{self.index}]当前奈雪币: {coin}')
|
||||
else:
|
||||
# 查询失败的逻辑处理
|
||||
Log(f'账号[{self.index}]查询失败')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def sign_record(self):
|
||||
try:
|
||||
sign_date = datetime.datetime.now().replace(day=1).strftime('%Y-%m-%d')
|
||||
today_date = datetime.datetime.now().strftime('%Y-%m-%d')
|
||||
api_options = {
|
||||
'fn': 'signRecord',
|
||||
'method': 'post',
|
||||
'url': 'https://tm-web.pin-dao.cn/user/sign/records',
|
||||
'body': {
|
||||
'signDate': sign_date,
|
||||
'startDate': today_date
|
||||
}
|
||||
}
|
||||
response = self.task_api(api_options)
|
||||
if response['code'] == 0:
|
||||
Log(f"今天{'已' if response['data']['status'] else '未'}签到,已签到{response['data']['signCount']}天")
|
||||
if not response['data']['status']:
|
||||
self.sign_save()
|
||||
else:
|
||||
Log(f"查询签到失败: {response['message']}")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def sign_save(self):
|
||||
try:
|
||||
sign_date = datetime.datetime.now().strftime('%Y-%m-%d')
|
||||
api_options = {
|
||||
'fn': 'signSave',
|
||||
'method': 'post',
|
||||
'url': 'https://tm-web.pin-dao.cn/user/sign/save',
|
||||
'body': {
|
||||
'signDate': sign_date
|
||||
}
|
||||
}
|
||||
response = self.task_api(api_options)
|
||||
if response['code'] == 0:
|
||||
if response['data']['flag']:
|
||||
Log('签到成功')
|
||||
else:
|
||||
Log('今天已经签到过了')
|
||||
else:
|
||||
print(f"签到失败: {response['message']}")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def main(self):
|
||||
Log(f"\n开始执行第{self.index}个账号--------------->>>>>")
|
||||
base_userinfo_result = self.base_userinfo()
|
||||
if not base_userinfo_result:
|
||||
Log("用户信息无效,请更新CK")
|
||||
return False
|
||||
self.sign_record()
|
||||
self.user_account()
|
||||
self.sendMsg()
|
||||
return True
|
||||
|
||||
def sendMsg(self, help=False):
|
||||
if self.send_UID:
|
||||
push_res = CHERWIN_TOOLS.wxpusher(self.send_UID, one_msg, APP_NAME, help)
|
||||
print(push_res)
|
||||
|
||||
|
||||
def down_file(filename, file_url):
|
||||
print(f'开始下载:{filename},下载地址:{file_url}')
|
||||
try:
|
||||
response = requests.get(file_url, verify=False, timeout=10)
|
||||
response.raise_for_status()
|
||||
with open(filename + '.tmp', 'wb') as f:
|
||||
f.write(response.content)
|
||||
print(f'【{filename}】下载完成!')
|
||||
|
||||
# 检查临时文件是否存在
|
||||
temp_filename = filename + '.tmp'
|
||||
if os.path.exists(temp_filename):
|
||||
# 删除原有文件
|
||||
if os.path.exists(filename):
|
||||
os.remove(filename)
|
||||
# 重命名临时文件
|
||||
os.rename(temp_filename, filename)
|
||||
print(f'【{filename}】重命名成功!')
|
||||
return True
|
||||
else:
|
||||
print(f'【{filename}】临时文件不存在!')
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f'【{filename}】下载失败:{str(e)}')
|
||||
return False
|
||||
|
||||
def import_Tools():
|
||||
global CHERWIN_TOOLS,ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
|
||||
import CHERWIN_TOOLS
|
||||
ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode = CHERWIN_TOOLS.main(APP_NAME, local_script_name, ENV_NAME,local_version)
|
||||
|
||||
if __name__ == '__main__':
|
||||
APP_NAME = '奈雪点单小程序'
|
||||
ENV_NAME = 'NXDD'
|
||||
CK_NAME = 'Authorization'
|
||||
print(f'''
|
||||
✨✨✨ {APP_NAME}签到✨✨✨
|
||||
✨ 功能:
|
||||
积分签到
|
||||
✨ 抓包步骤:
|
||||
打开{APP_NAME}
|
||||
授权登陆
|
||||
打开抓包工具
|
||||
找请求头带{CK_NAME}的URl
|
||||
复制里面的{CK_NAME}参数值【不要】前面的Bearer 【不要】前面的Bearer 【不要】前面的Bearer
|
||||
参数示例:eyJhbGciOiJxxxxxxxxxxxx
|
||||
✨ 设置青龙变量:
|
||||
export {ENV_NAME}='{CK_NAME}参数值【不要】前面的Bearer'多账号#或&分割
|
||||
export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨ ✨ 注意:抓完CK没事儿别打开小程序,重新打开小程序请重新抓包
|
||||
✨ 推荐cron:30 1 * * *
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.04.06'
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://py.cherwin.cn/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://py.cherwin.cn/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
if not token:
|
||||
print(f"未填写{ENV_NAME}变量\n青龙可在环境变量设置 {ENV_NAME} 或者在本脚本文件上方将{CK_NAME}填入token =''")
|
||||
exit()
|
||||
tokens = CHERWIN_TOOLS.ENV_SPLIT(token)
|
||||
# print(tokens)
|
||||
if len(tokens) > 0:
|
||||
print(f"\n>>>>>>>>>>共获取到{len(tokens)}个账号<<<<<<<<<<")
|
||||
access_token = []
|
||||
for index, infos in enumerate(tokens):
|
||||
run_result = RUN(infos, index).main()
|
||||
if not run_result: continue
|
||||
if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|
||||
# !/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
# -------------------------------
|
||||
# @Author CHERWIN✨✨✨
|
||||
# -------------------------------
|
||||
# cron "30 1 * * *" script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('奈雪小程序签到')
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import requests
|
||||
import hashlib
|
||||
import hmac
|
||||
import base64
|
||||
import time
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
else:
|
||||
print("加载通知服务失败!")
|
||||
send_msg = ''
|
||||
one_msg=''
|
||||
def Log(cont=''):
|
||||
global send_msg,one_msg
|
||||
print(cont)
|
||||
if cont:
|
||||
one_msg += f'{cont}\n'
|
||||
send_msg += f'{cont}\n'
|
||||
|
||||
class RUN:
|
||||
def __init__(self,info,index):
|
||||
global one_msg
|
||||
one_msg = ''
|
||||
split_info = info.split('@')
|
||||
token = split_info[0]
|
||||
len_split_info = len(split_info)
|
||||
last_info = split_info[len_split_info - 1]
|
||||
self.send_UID = None
|
||||
if len_split_info > 0 and "UID_" in last_info:
|
||||
print('检测到设置了UID')
|
||||
print(last_info)
|
||||
self.send_UID = last_info
|
||||
self.index = index + 1
|
||||
self.s = requests.session()
|
||||
self.s.verify = False
|
||||
|
||||
self.token = f'Bearer {token}'
|
||||
self.UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF XWEB/6945'
|
||||
self.openId = 'QL6ZOftGzbziPlZwfiXM'
|
||||
|
||||
def random_string(self,length=6, chars='123456789'):
|
||||
return ''.join(random.choice(chars) for _ in range(length))
|
||||
|
||||
def get_body(self):
|
||||
nonce = int(self.random_string())
|
||||
timestamp = int(time.time())
|
||||
url_path = f'nonce={nonce}&openId={self.openId}×tamp={timestamp}'
|
||||
signature = base64.b64encode(
|
||||
hmac.new('sArMTldQ9tqU19XIRDMWz7BO5WaeBnrezA'.encode(), url_path.encode(), hashlib.sha1).digest()).decode()
|
||||
common = {
|
||||
'platform': 'wxapp',
|
||||
'version': '5.1.8',
|
||||
'imei': '',
|
||||
'osn': 'microsoft',
|
||||
'sv': 'Windows 10 x64',
|
||||
'lang': 'zh_CN',
|
||||
'currency': 'CNY',
|
||||
'timeZone': '',
|
||||
'nonce': nonce,
|
||||
'openId': self.openId,
|
||||
'timestamp': timestamp,
|
||||
'signature': signature
|
||||
}
|
||||
params = {
|
||||
'businessType': 1,
|
||||
'brand': 26000252,
|
||||
'tenantId': 1,
|
||||
'channel': 2,
|
||||
'stallType': None,
|
||||
'storeId': None
|
||||
}
|
||||
|
||||
requestData = {
|
||||
'common': common,
|
||||
'params': params
|
||||
}
|
||||
return requestData
|
||||
|
||||
def task_api(self,api_options=None):
|
||||
if api_options is None:
|
||||
api_options = {}
|
||||
try:
|
||||
# 首先解析URL,获得主机名
|
||||
host_name = api_options['url'].replace('//', '/').split('/')[1]
|
||||
full_url = api_options['url']
|
||||
if 'queryParam' in api_options:
|
||||
# 如果存在查询参数,将其附加到URL
|
||||
query_str = "&".join(f"{k}={v}" for k, v in api_options['queryParam'].items())
|
||||
full_url += '?' + query_str
|
||||
# 定义请求头
|
||||
headers = {
|
||||
'Host': host_name,
|
||||
'Connection': 'keep-alive',
|
||||
'User-Agent': self.UA,
|
||||
'Authorization': self.token,
|
||||
'Referer': 'https://tm-web.pin-dao.cn/',
|
||||
'Origin': 'https://tm-web.pin-dao.cn'
|
||||
}
|
||||
# 准备请求体
|
||||
data = None
|
||||
if 'body' in api_options:
|
||||
body = self.get_body()
|
||||
body['params'].update(api_options['body'])
|
||||
content_type = api_options.get('Content-Type', 'application/json')
|
||||
headers['Content-Type'] = content_type
|
||||
if 'json' in content_type:
|
||||
data = json.dumps(body)
|
||||
else:
|
||||
data = "&".join(f"{k}={json.dumps(v) if isinstance(v, dict) else v}" for k, v in body.items())
|
||||
headers['Content-Length'] = str(len(data))
|
||||
# 如果有额外的URL参数或头部参数,合并到请求中
|
||||
if 'urlObjectParam' in api_options:
|
||||
# 这里根据需要处理urlObjectParam
|
||||
pass
|
||||
if 'headerParam' in api_options:
|
||||
headers.update(api_options['headerParam'])
|
||||
# 发出请求
|
||||
response = requests.request(method=api_options.get('method', 'GET'), url=full_url, headers=headers,
|
||||
data=data, timeout=20,verify=False)
|
||||
# 打印状态码
|
||||
if response.status_code != 200:
|
||||
print(f"[{api_options.get('fn', 'unknown function')}]返回[{response.status_code}]")
|
||||
|
||||
# 解析结果
|
||||
try:
|
||||
result = response.json()
|
||||
except ValueError:
|
||||
result = response.text
|
||||
return result
|
||||
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
return {}
|
||||
|
||||
def base_userinfo(self):
|
||||
try:
|
||||
api_options = {
|
||||
'fn': 'baseUserinfo',
|
||||
'method': 'post',
|
||||
'url': 'https://tm-web.pin-dao.cn/user/base-userinfo',
|
||||
'body': {}
|
||||
}
|
||||
response = self.task_api(api_options)
|
||||
if response['code'] == 0:
|
||||
# 登录成功的逻辑处理
|
||||
phone = response['data']['phone']
|
||||
self.phone = phone[:3] + "*" * 4 + phone[7:]
|
||||
self.userId = response['data']['userId']
|
||||
self.nickName = response['data']['nickName']
|
||||
Log(f'账号[{self.index}]登录成功!\n手机号:[{self.phone}] ID[{self.userId}]')
|
||||
# print(one_msg)
|
||||
return True
|
||||
else:
|
||||
# 登录失败的逻辑处理
|
||||
Log(f"账号登录失败: {response['message']}")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def user_account(self):
|
||||
try:
|
||||
api_options = {
|
||||
'fn': 'userAccount',
|
||||
'method': 'post',
|
||||
'url': 'https://tm-web.pin-dao.cn/user/account/user-account',
|
||||
'body': {}
|
||||
}
|
||||
response = self.task_api(api_options)
|
||||
if response['code'] == 0:
|
||||
# 查询成功的逻辑处理
|
||||
coin = response['data']['coin']
|
||||
Log(f'账号[{self.index}]当前奈雪币: {coin}')
|
||||
else:
|
||||
# 查询失败的逻辑处理
|
||||
Log(f'账号[{self.index}]查询失败')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def sign_record(self):
|
||||
try:
|
||||
sign_date = datetime.datetime.now().replace(day=1).strftime('%Y-%m-%d')
|
||||
today_date = datetime.datetime.now().strftime('%Y-%m-%d')
|
||||
api_options = {
|
||||
'fn': 'signRecord',
|
||||
'method': 'post',
|
||||
'url': 'https://tm-web.pin-dao.cn/user/sign/records',
|
||||
'body': {
|
||||
'signDate': sign_date,
|
||||
'startDate': today_date
|
||||
}
|
||||
}
|
||||
response = self.task_api(api_options)
|
||||
if response['code'] == 0:
|
||||
Log(f"今天{'已' if response['data']['status'] else '未'}签到,已签到{response['data']['signCount']}天")
|
||||
if not response['data']['status']:
|
||||
self.sign_save()
|
||||
else:
|
||||
Log(f"查询签到失败: {response['message']}")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def sign_save(self):
|
||||
try:
|
||||
sign_date = datetime.datetime.now().strftime('%Y-%m-%d')
|
||||
api_options = {
|
||||
'fn': 'signSave',
|
||||
'method': 'post',
|
||||
'url': 'https://tm-web.pin-dao.cn/user/sign/save',
|
||||
'body': {
|
||||
'signDate': sign_date
|
||||
}
|
||||
}
|
||||
response = self.task_api(api_options)
|
||||
if response['code'] == 0:
|
||||
if response['data']['flag']:
|
||||
Log('签到成功')
|
||||
else:
|
||||
Log('今天已经签到过了')
|
||||
else:
|
||||
print(f"签到失败: {response['message']}")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def main(self):
|
||||
Log(f"\n开始执行第{self.index}个账号--------------->>>>>")
|
||||
base_userinfo_result = self.base_userinfo()
|
||||
if not base_userinfo_result:
|
||||
Log("用户信息无效,请更新CK")
|
||||
return False
|
||||
self.sign_record()
|
||||
self.user_account()
|
||||
self.sendMsg()
|
||||
return True
|
||||
|
||||
def sendMsg(self, help=False):
|
||||
if self.send_UID:
|
||||
push_res = CHERWIN_TOOLS.wxpusher(self.send_UID, one_msg, APP_NAME, help)
|
||||
print(push_res)
|
||||
|
||||
|
||||
def down_file(filename, file_url):
|
||||
print(f'开始下载:{filename},下载地址:{file_url}')
|
||||
try:
|
||||
response = requests.get(file_url, verify=False, timeout=10)
|
||||
response.raise_for_status()
|
||||
with open(filename + '.tmp', 'wb') as f:
|
||||
f.write(response.content)
|
||||
print(f'【{filename}】下载完成!')
|
||||
|
||||
# 检查临时文件是否存在
|
||||
temp_filename = filename + '.tmp'
|
||||
if os.path.exists(temp_filename):
|
||||
# 删除原有文件
|
||||
if os.path.exists(filename):
|
||||
os.remove(filename)
|
||||
# 重命名临时文件
|
||||
os.rename(temp_filename, filename)
|
||||
print(f'【{filename}】重命名成功!')
|
||||
return True
|
||||
else:
|
||||
print(f'【{filename}】临时文件不存在!')
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f'【{filename}】下载失败:{str(e)}')
|
||||
return False
|
||||
|
||||
def import_Tools():
|
||||
global CHERWIN_TOOLS,ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
|
||||
import CHERWIN_TOOLS
|
||||
ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode = CHERWIN_TOOLS.main(APP_NAME, local_script_name, ENV_NAME,local_version)
|
||||
|
||||
if __name__ == '__main__':
|
||||
APP_NAME = '奈雪点单小程序'
|
||||
ENV_NAME = 'NXDD'
|
||||
CK_NAME = 'Authorization'
|
||||
print(f'''
|
||||
✨✨✨ {APP_NAME}签到✨✨✨
|
||||
✨ 功能:
|
||||
积分签到
|
||||
✨ 抓包步骤:
|
||||
打开{APP_NAME}
|
||||
授权登陆
|
||||
打开抓包工具
|
||||
找请求头带{CK_NAME}的URl
|
||||
复制里面的{CK_NAME}参数值【不要】前面的Bearer 【不要】前面的Bearer 【不要】前面的Bearer
|
||||
参数示例:eyJhbGciOiJxxxxxxxxxxxx
|
||||
✨ 设置青龙变量:
|
||||
export {ENV_NAME}='{CK_NAME}参数值【不要】前面的Bearer'多账号#或&分割
|
||||
export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨ ✨ 注意:抓完CK没事儿别打开小程序,重新打开小程序请重新抓包
|
||||
✨ 推荐cron:30 1 * * *
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
if not token:
|
||||
print(f"未填写{ENV_NAME}变量\n青龙可在环境变量设置 {ENV_NAME} 或者在本脚本文件上方将{CK_NAME}填入token =''")
|
||||
exit()
|
||||
tokens = CHERWIN_TOOLS.ENV_SPLIT(token)
|
||||
# print(tokens)
|
||||
if len(tokens) > 0:
|
||||
print(f"\n>>>>>>>>>>共获取到{len(tokens)}个账号<<<<<<<<<<")
|
||||
access_token = []
|
||||
for index, infos in enumerate(tokens):
|
||||
run_result = RUN(infos, index).main()
|
||||
if not run_result: continue
|
||||
if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|
||||
|
||||
367
SFSY.py
367
SFSY.py
@ -13,28 +13,37 @@ from datetime import datetime, timedelta
|
||||
from sys import exit
|
||||
import requests
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
|
||||
print("加载通知服务成功!")
|
||||
else:
|
||||
print("加载通知服务失败!")
|
||||
send_msg = ''
|
||||
one_msg=''
|
||||
one_msg = ''
|
||||
|
||||
|
||||
def Log(cont=''):
|
||||
global send_msg,one_msg
|
||||
global send_msg, one_msg
|
||||
print(cont)
|
||||
if cont:
|
||||
one_msg += f'{cont}\n'
|
||||
send_msg += f'{cont}\n'
|
||||
#1905 #0945 #6332 #6615 2559
|
||||
inviteId=['8C3950A023D942FD93BE9218F5BFB34B','EF94619ED9C84E968C7A88CFB5E0B5DC','9C92BD3D672D4B6EBB7F4A488D020C79','803CF9D1E0734327BDF67CDAE1442B0E','00C81F67BE374041A692FA034847F503']
|
||||
|
||||
# 1905 #0945 #6332 #6615 2559
|
||||
inviteId = [
|
||||
'8C3950A023D942FD93BE9218F5BFB34B', 'EF94619ED9C84E968C7A88CFB5E0B5DC', '9C92BD3D672D4B6EBB7F4A488D020C79','803CF9D1E0734327BDF67CDAE1442B0E', '00C81F67BE374041A692FA034847F503']
|
||||
class RUN:
|
||||
def __init__(self,info,index):
|
||||
def __init__(self, info, index):
|
||||
global one_msg
|
||||
one_msg = ''
|
||||
split_info = info.split('@')
|
||||
@ -62,9 +71,12 @@ class RUN:
|
||||
|
||||
}
|
||||
self.anniversary_black = False
|
||||
self.member_day_black = False
|
||||
self.member_day_red_packet_drew_today = False
|
||||
self.member_day_red_packet_map = {}
|
||||
self.login_res = self.login(url)
|
||||
self.today = datetime.now().strftime('%Y-%m-%d')
|
||||
self.answer = APP_INFO.get('ANSWER',[]).get(self.today,False)
|
||||
self.answer = APP_INFO.get('ANSWER', []).get(self.today, False)
|
||||
|
||||
def get_deviceId(self, characters='abcdef0123456789'):
|
||||
result = ''
|
||||
@ -77,7 +89,7 @@ class RUN:
|
||||
result += char
|
||||
return result
|
||||
|
||||
def login(self,sfurl):
|
||||
def login(self, sfurl):
|
||||
ress = self.s.get(sfurl, headers=self.headers)
|
||||
# print(ress.text)
|
||||
self.user_id = self.s.cookies.get_dict().get('_login_user_id_', '')
|
||||
@ -89,6 +101,7 @@ class RUN:
|
||||
else:
|
||||
Log(f'获取用户信息失败')
|
||||
return False
|
||||
|
||||
def getSign(self):
|
||||
timestamp = str(int(round(time.time() * 1000)))
|
||||
token = 'wwesldfs29aniversaryvdld29'
|
||||
@ -102,7 +115,8 @@ class RUN:
|
||||
}
|
||||
self.headers.update(data)
|
||||
return data
|
||||
def do_request(self, url, data = {}, req_type = 'post'):
|
||||
|
||||
def do_request(self, url, data={}, req_type='post'):
|
||||
self.getSign()
|
||||
try:
|
||||
if req_type.lower() == 'get':
|
||||
@ -120,20 +134,19 @@ class RUN:
|
||||
print('JSON decoding failed:', e)
|
||||
return None
|
||||
|
||||
|
||||
def sign(self):
|
||||
print(f'>>>>>>开始执行签到')
|
||||
json_data = {"comeFrom":"vioin","channelFrom":"WEIXIN"}
|
||||
json_data = {"comeFrom": "vioin", "channelFrom": "WEIXIN"}
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~integralTaskSignPlusService~automaticSignFetchPackage'
|
||||
response = self.do_request(url, data=json_data)
|
||||
# print(response)
|
||||
if response.get('success') == True:
|
||||
count_day = response.get('obj',{}).get('countDay',0)
|
||||
count_day = response.get('obj', {}).get('countDay', 0)
|
||||
if response.get('obj') and response['obj'].get('integralTaskSignPackageVOList'):
|
||||
packet_name = response["obj"]["integralTaskSignPackageVOList"][0]["packetName"]
|
||||
Log(f'>>>签到成功,获得【{packet_name}】,本周累计签到【{count_day+1}】天')
|
||||
Log(f'>>>签到成功,获得【{packet_name}】,本周累计签到【{count_day + 1}】天')
|
||||
else:
|
||||
Log(f'今日已签到,本周累计签到【{count_day+1}】天')
|
||||
Log(f'今日已签到,本周累计签到【{count_day + 1}】天')
|
||||
else:
|
||||
print(f'签到失败!原因:{response.get("errorMessage")}')
|
||||
|
||||
@ -143,7 +156,7 @@ class RUN:
|
||||
'channel': 'czflqdlhbxcx'
|
||||
}
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberActLengthy~redPacketActivityService~superWelfare~receiveRedPacket'
|
||||
response = self.do_request(url,data=json_data)
|
||||
response = self.do_request(url, data=json_data)
|
||||
# print(response)
|
||||
if response.get('success') == True:
|
||||
gift_list = response.get('obj', {}).get('giftList', [])
|
||||
@ -157,16 +170,16 @@ class RUN:
|
||||
error_message = response.get('errorMessage') or json.dumps(response) or '无返回'
|
||||
print(f'超值福利签到失败: {error_message}')
|
||||
|
||||
def get_SignTaskList(self,END=False):
|
||||
if not END:print(f'>>>开始获取签到任务列表')
|
||||
def get_SignTaskList(self, END=False):
|
||||
if not END: print(f'>>>开始获取签到任务列表')
|
||||
json_data = {
|
||||
'channelType': '3',
|
||||
'deviceId': self.get_deviceId(),
|
||||
}
|
||||
url='https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~integralTaskStrategyService~queryPointTaskAndSignFromES'
|
||||
response = self.do_request(url,data=json_data)
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~integralTaskStrategyService~queryPointTaskAndSignFromES'
|
||||
response = self.do_request(url, data=json_data)
|
||||
# print(response)
|
||||
if response.get('success') == True and response.get('obj') !=[]:
|
||||
if response.get('success') == True and response.get('obj') != []:
|
||||
totalPoint = response["obj"]["totalPoint"]
|
||||
if END:
|
||||
Log(f'当前积分:【{totalPoint}】')
|
||||
@ -178,7 +191,7 @@ class RUN:
|
||||
self.strategyId = task["strategyId"]
|
||||
self.title = task["title"]
|
||||
status = task["status"]
|
||||
skip_title = ['用行业模板寄件下单','去新增一个收件偏好','参与积分活动']
|
||||
skip_title = ['用行业模板寄件下单', '去新增一个收件偏好', '参与积分活动']
|
||||
if status == 3:
|
||||
print(f'>{self.title}-已完成')
|
||||
continue
|
||||
@ -198,8 +211,8 @@ class RUN:
|
||||
json_data = {
|
||||
'taskCode': self.taskCode,
|
||||
}
|
||||
url='https://mcs-mimp-web.sf-express.com/mcs-mimp/commonRoutePost/memberEs/taskRecord/finishTask'
|
||||
response = self.do_request(url,data=json_data)
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonRoutePost/memberEs/taskRecord/finishTask'
|
||||
response = self.do_request(url, data=json_data)
|
||||
if response.get('success') == True:
|
||||
print(f'>【{self.title}】任务-已完成')
|
||||
else:
|
||||
@ -233,11 +246,11 @@ class RUN:
|
||||
def receive_honeyTask(self):
|
||||
print('>>>执行收取丰蜜任务')
|
||||
# 收取
|
||||
self.headers['syscode']='MCS-MIMP-CORE'
|
||||
self.headers['channel']='wxwdsj'
|
||||
self.headers['accept']='application/json, text/plain, */*'
|
||||
self.headers['content-type']='application/json;charset=UTF-8'
|
||||
self.headers['platform']='MINI_PROGRAM'
|
||||
self.headers['syscode'] = 'MCS-MIMP-CORE'
|
||||
self.headers['channel'] = 'wxwdsj'
|
||||
self.headers['accept'] = 'application/json, text/plain, */*'
|
||||
self.headers['content-type'] = 'application/json;charset=UTF-8'
|
||||
self.headers['platform'] = 'MINI_PROGRAM'
|
||||
json_data = {"taskType": self.taskType}
|
||||
# print(json_data)
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~receiveExchangeIndexService~receiveHoney'
|
||||
@ -295,8 +308,8 @@ class RUN:
|
||||
print('>>>开始获取采蜜换大礼任务列表')
|
||||
# 任务列表
|
||||
json_data = {}
|
||||
self.headers['channel']='wxwdsj'
|
||||
url ='https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~receiveExchangeIndexService~taskDetail'
|
||||
self.headers['channel'] = 'wxwdsj'
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~receiveExchangeIndexService~taskDetail'
|
||||
|
||||
response = self.do_request(url, data=json_data)
|
||||
# print(response)
|
||||
@ -323,11 +336,11 @@ class RUN:
|
||||
print('>>>执行大冒险任务')
|
||||
# 大冒险
|
||||
gameNum = 5
|
||||
for i in range(1,gameNum):
|
||||
for i in range(1, gameNum):
|
||||
json_data = {
|
||||
'gatherHoney': 20,
|
||||
}
|
||||
if gameNum < 0 :break
|
||||
if gameNum < 0: break
|
||||
print(f'>>开始第{i}次大冒险')
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~receiveExchangeGameService~gameReport'
|
||||
response = self.do_request(url, data=json_data)
|
||||
@ -342,8 +355,8 @@ class RUN:
|
||||
print(f'>大冒险失败!【{response.get("errorMessage")}】')
|
||||
break
|
||||
|
||||
def honey_indexData(self,END=False):
|
||||
if not END:print('\n>>>>>>>开始执行采蜜换大礼任务')
|
||||
def honey_indexData(self, END=False):
|
||||
if not END: print('\n>>>>>>>开始执行采蜜换大礼任务')
|
||||
# 邀请
|
||||
random_invite = random.choice([invite for invite in inviteId if invite != self.user_id])
|
||||
self.headers['channel'] = 'wxwdsj'
|
||||
@ -357,7 +370,7 @@ class RUN:
|
||||
return
|
||||
Log(f'执行前丰蜜:【{usableHoney}】')
|
||||
taskDetail = response.get('obj').get('taskDetail')
|
||||
activityEndTime = response.get('obj').get('activityEndTime','')
|
||||
activityEndTime = response.get('obj').get('activityEndTime', '')
|
||||
activity_end_time = datetime.strptime(activityEndTime, "%Y-%m-%d %H:%M:%S")
|
||||
current_time = datetime.now()
|
||||
|
||||
@ -372,8 +385,6 @@ class RUN:
|
||||
self.receive_honeyTask()
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
|
||||
def EAR_END_2023_TaskList(self):
|
||||
print('\n>>>>>>开始年终集卡任务')
|
||||
# 任务列表
|
||||
@ -381,11 +392,11 @@ class RUN:
|
||||
"activityCode": "YEAR_END_2023",
|
||||
"channelType": "MINI_PROGRAM"
|
||||
}
|
||||
self.headers['channel']='xcx23nz'
|
||||
self.headers['platform']='MINI_PROGRAM'
|
||||
self.headers['syscode']='MCS-MIMP-CORE'
|
||||
self.headers['channel'] = 'xcx23nz'
|
||||
self.headers['platform'] = 'MINI_PROGRAM'
|
||||
self.headers['syscode'] = 'MCS-MIMP-CORE'
|
||||
|
||||
url ='https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~activityTaskService~taskList'
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~activityTaskService~taskList'
|
||||
|
||||
response = self.do_request(url, data=json_data)
|
||||
# print(response)
|
||||
@ -476,7 +487,7 @@ class RUN:
|
||||
print(f'>>>开始抽卡')
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~yearEnd2023GardenPartyService~getAward'
|
||||
for l in range(10):
|
||||
for i in range(0,3):
|
||||
for i in range(0, 3):
|
||||
json_data = {
|
||||
"cardType": i
|
||||
}
|
||||
@ -497,7 +508,7 @@ class RUN:
|
||||
def EAR_END_2023_GuessIdiom(self):
|
||||
print(f'>>>开始猜成语')
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~yearEnd2023GuessIdiomService~win'
|
||||
for i in range(1,11):
|
||||
for i in range(1, 11):
|
||||
json_data = {
|
||||
"index": i
|
||||
}
|
||||
@ -545,6 +556,7 @@ class RUN:
|
||||
print(f'查询每周领券失败: {error_message}')
|
||||
if '系统繁忙' in error_message or '用户手机号校验未通过' in error_message:
|
||||
self.anniversary_black = True
|
||||
|
||||
def anniversary2024_receive_weekly_gift(self):
|
||||
print(f'>>>开始领取每周领券')
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024IndexService~receiveWeeklyGift'
|
||||
@ -554,7 +566,7 @@ class RUN:
|
||||
print(f'每周领券: {product_names}')
|
||||
else:
|
||||
error_message = response.get('errorMessage') or json.dumps(response) or '无返回'
|
||||
print( f'每周领券失败: {error_message}')
|
||||
print(f'每周领券失败: {error_message}')
|
||||
if '系统繁忙' in error_message or '用户手机号校验未通过' in error_message:
|
||||
self.anniversary_black = True
|
||||
|
||||
@ -581,13 +593,17 @@ class RUN:
|
||||
pass
|
||||
elif task['taskType'] == 'FOLLOW_SFZHUNONG_VEDIO_ID':
|
||||
pass
|
||||
elif task['taskType'] in ['BROWSE_VIP_CENTER', 'GUESS_GAME_TIP', 'CREATE_SFID', 'CLICK_MY_SETTING', 'CLICK_TEMPLATE', 'REAL_NAME', 'SEND_SUCCESS_RECALL', 'OPEN_SVIP', 'OPEN_FAST_CARD', 'FIRST_CHARGE_NEW_EXPRESS_CARD', 'CHARGE_NEW_EXPRESS_CARD', 'INTEGRAL_EXCHANGE']:
|
||||
elif task['taskType'] in ['BROWSE_VIP_CENTER', 'GUESS_GAME_TIP', 'CREATE_SFID', 'CLICK_MY_SETTING',
|
||||
'CLICK_TEMPLATE', 'REAL_NAME', 'SEND_SUCCESS_RECALL', 'OPEN_SVIP',
|
||||
'OPEN_FAST_CARD', 'FIRST_CHARGE_NEW_EXPRESS_CARD', 'CHARGE_NEW_EXPRESS_CARD',
|
||||
'INTEGRAL_EXCHANGE']:
|
||||
pass
|
||||
else:
|
||||
for _ in range(task['restFinishTime']):
|
||||
if self.anniversary_black:
|
||||
break
|
||||
self.anniversary2024_finishTask(task)
|
||||
|
||||
def anniversary2024_finishTask(self, task):
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonRoutePost/memberEs/taskRecord/finishTask'
|
||||
data = {'taskCode': task['taskCode']}
|
||||
@ -597,7 +613,8 @@ class RUN:
|
||||
# 完成任务后获取任务奖励的逻辑
|
||||
self.anniversary2024_fetchMixTaskReward(task)
|
||||
else:
|
||||
print('完成任务[%s]失败: %s' % (task['taskName'], response.get('errorMessage') or (json.dumps(response) if response else '无返回')))
|
||||
print('完成任务[%s]失败: %s' % (
|
||||
task['taskName'], response.get('errorMessage') or (json.dumps(response) if response else '无返回')))
|
||||
|
||||
def anniversary2024_fetchMixTaskReward(self, task):
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024TaskService~fetchMixTaskReward'
|
||||
@ -885,7 +902,7 @@ class RUN:
|
||||
self.cards[currency_key] = int(card.get('balance'))
|
||||
card_info.append('[' + card.get('currency') + ']X' + str(card.get('balance')))
|
||||
|
||||
Log(f'已收集拼图: {card_info}' )
|
||||
Log(f'已收集拼图: {card_info}')
|
||||
cards_li.sort(key=lambda x: x.get('balance'), reverse=True)
|
||||
|
||||
else:
|
||||
@ -896,11 +913,11 @@ class RUN:
|
||||
|
||||
def do_draw(self, cards):
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024CardService~collectDrawAward'
|
||||
data = {"accountList":cards}
|
||||
data = {"accountList": cards}
|
||||
response = self.do_request(url, data)
|
||||
if response and response.get('success'):
|
||||
data = response.get('obj',{})
|
||||
productName = data.get('productName','')
|
||||
data = response.get('obj', {})
|
||||
productName = data.get('productName', '')
|
||||
Log(f'抽奖成功,获得{productName}')
|
||||
return True
|
||||
else:
|
||||
@ -908,7 +925,7 @@ class RUN:
|
||||
print(f'抽奖失败: {error_message}')
|
||||
return False
|
||||
|
||||
def convert_common_card(self,cards, target_card):
|
||||
def convert_common_card(self, cards, target_card):
|
||||
# 如果共通卡(COMMON_CARD)的数量大于0,转化成目标卡
|
||||
if cards['COMMON_CARD'] > 0:
|
||||
cards['COMMON_CARD'] -= 1
|
||||
@ -916,13 +933,12 @@ class RUN:
|
||||
return True
|
||||
return False
|
||||
|
||||
def can_draw(self,cards, n):
|
||||
def can_draw(self, cards, n):
|
||||
# 判断是否有足够的不同卡进行抽奖
|
||||
distinct_cards = sum(1 for card, amount in cards.items() if card != 'COMMON_CARD' and amount > 0)
|
||||
return distinct_cards >= n
|
||||
|
||||
|
||||
def draw(self,cards, n):
|
||||
def draw(self, cards, n):
|
||||
drawn_cards = []
|
||||
for card, amount in sorted(cards.items(), key=lambda item: item[1]):
|
||||
if card != 'COMMON_CARD' and amount > 0:
|
||||
@ -937,7 +953,7 @@ class RUN:
|
||||
else:
|
||||
return None
|
||||
|
||||
def simulate_lottery(self,cards):
|
||||
def simulate_lottery(self, cards):
|
||||
while self.can_draw(cards, 9):
|
||||
used_cards = self.draw(cards, 9)
|
||||
print("进行了一次9卡抽奖,消耗卡片: ", used_cards)
|
||||
@ -973,15 +989,210 @@ class RUN:
|
||||
else:
|
||||
print('未到自动抽奖时间')
|
||||
|
||||
def member_day_index(self):
|
||||
try:
|
||||
invite_user_id = random.choice([invite for invite in inviteId if invite != self.user_id])
|
||||
payload = {'inviteUserId': invite_user_id}
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~memberDayIndexService~index'
|
||||
|
||||
response = self.do_request(url, data=payload)
|
||||
if response.get('success'):
|
||||
lottery_num = response.get('obj', {}).get('lotteryNum', 0)
|
||||
can_receive_invite_award = response.get('obj', {}).get('canReceiveInviteAward', False)
|
||||
if can_receive_invite_award:
|
||||
self.member_day_receive_invite_award(invite_user_id)
|
||||
self.member_day_red_packet_status()
|
||||
Log(f'会员日可以抽奖{lottery_num}次')
|
||||
for _ in range(lottery_num):
|
||||
self.member_day_lottery()
|
||||
if self.member_day_black:
|
||||
return
|
||||
self.member_day_task_list()
|
||||
if self.member_day_black:
|
||||
return
|
||||
self.member_day_red_packet_status()
|
||||
else:
|
||||
error_message = response.get('errorMessage', '无返回')
|
||||
Log(f'查询会员日失败: {error_message}')
|
||||
if '没有资格参与活动' in error_message:
|
||||
self.member_day_black = True
|
||||
Log('会员日任务风控')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def member_day_receive_invite_award(self, invite_user_id):
|
||||
try:
|
||||
payload = {'inviteUserId': invite_user_id}
|
||||
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~memberDayIndexService~receiveInviteAward'
|
||||
|
||||
response = self.do_request(url, payload)
|
||||
if response.get('success'):
|
||||
product_name = response.get('obj', {}).get('productName', '空气')
|
||||
Log(f'会员日奖励: {product_name}')
|
||||
else:
|
||||
error_message = response.get('errorMessage', '无返回')
|
||||
Log(f'领取会员日奖励失败: {error_message}')
|
||||
if '没有资格参与活动' in error_message:
|
||||
self.member_day_black = True
|
||||
Log('会员日任务风控')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def member_day_lottery(self):
|
||||
try:
|
||||
payload = {}
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~memberDayLotteryService~lottery'
|
||||
|
||||
response = self.do_request(url, payload)
|
||||
if response.get('success'):
|
||||
product_name = response.get('obj', {}).get('productName', '空气')
|
||||
Log(f'会员日抽奖: {product_name}')
|
||||
else:
|
||||
error_message = response.get('errorMessage', '无返回')
|
||||
Log(f'会员日抽奖失败: {error_message}')
|
||||
if '没有资格参与活动' in error_message:
|
||||
self.member_day_black = True
|
||||
Log('会员日任务风控')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def member_day_task_list(self):
|
||||
try:
|
||||
payload = {'activityCode': 'MEMBER_DAY', 'channelType': 'MINI_PROGRAM'}
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~activityTaskService~taskList'
|
||||
|
||||
response = self.do_request(url, payload)
|
||||
if response.get('success'):
|
||||
task_list = response.get('obj', [])
|
||||
for task in task_list:
|
||||
if task['status'] == 1:
|
||||
if self.member_day_black:
|
||||
return
|
||||
self.member_day_fetch_mix_task_reward(task)
|
||||
for task in task_list:
|
||||
if task['status'] == 2:
|
||||
if self.member_day_black:
|
||||
return
|
||||
if task['taskType'] in ['SEND_SUCCESS', 'INVITEFRIENDS_PARTAKE_ACTIVITY', 'OPEN_SVIP',
|
||||
'OPEN_NEW_EXPRESS_CARD', 'OPEN_FAMILY_CARD', 'CHARGE_NEW_EXPRESS_CARD',
|
||||
'INTEGRAL_EXCHANGE']:
|
||||
pass
|
||||
else:
|
||||
for _ in range(task['restFinishTime']):
|
||||
if self.member_day_black:
|
||||
return
|
||||
self.member_day_finish_task(task)
|
||||
else:
|
||||
error_message = response.get('errorMessage', '无返回')
|
||||
Log('查询会员日任务失败: ' + error_message)
|
||||
if '没有资格参与活动' in error_message:
|
||||
self.member_day_black = True
|
||||
Log('会员日任务风控')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def member_day_finish_task(self, task):
|
||||
try:
|
||||
payload = {'taskCode': task['taskCode']}
|
||||
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberEs~taskRecord~finishTask'
|
||||
|
||||
response = self.do_request(url, payload)
|
||||
if response.get('success'):
|
||||
Log('完成会员日任务[' + task['taskName'] + ']成功')
|
||||
self.member_day_fetch_mix_task_reward(task)
|
||||
else:
|
||||
error_message = response.get('errorMessage', '无返回')
|
||||
Log('完成会员日任务[' + task['taskName'] + ']失败: ' + error_message)
|
||||
if '没有资格参与活动' in error_message:
|
||||
self.member_day_black = True
|
||||
Log('会员日任务风控')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def member_day_fetch_mix_task_reward(self, task):
|
||||
try:
|
||||
payload = {'taskType': task['taskType'], 'activityCode': 'MEMBER_DAY', 'channelType': 'MINI_PROGRAM'}
|
||||
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~activityTaskService~fetchMixTaskReward'
|
||||
|
||||
response = self.do_request(url, payload)
|
||||
if response.get('success'):
|
||||
Log('领取会员日任务[' + task['taskName'] + ']奖励成功')
|
||||
else:
|
||||
error_message = response.get('errorMessage', '无返回')
|
||||
Log('领取会员日任务[' + task['taskName'] + ']奖励失败: ' + error_message)
|
||||
if '没有资格参与活动' in error_message:
|
||||
self.member_day_black = True
|
||||
Log('会员日任务风控')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def member_day_receive_red_packet(self, hour):
|
||||
try:
|
||||
payload = {'receiveHour': hour}
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~memberDayTaskService~receiveRedPacket'
|
||||
|
||||
response = self.do_request(url, payload)
|
||||
if response.get('success'):
|
||||
Log(f'会员日领取{hour}点红包成功')
|
||||
else:
|
||||
error_message = response.get('errorMessage', '无返回')
|
||||
Log(f'会员日领取{hour}点红包失败: {error_message}')
|
||||
if '没有资格参与活动' in error_message:
|
||||
self.member_day_black = True
|
||||
Log('会员日任务风控')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def member_day_red_packet_status(self):
|
||||
try:
|
||||
payload = {}
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~memberDayPacketService~redPacketStatus'
|
||||
response = self.do_request(url, payload)
|
||||
if response.get('success'):
|
||||
packet_list = response.get('obj', {}).get('packetList', [])
|
||||
for packet in packet_list:
|
||||
self.member_day_red_packet_map[packet['level']] = packet['count']
|
||||
# Rest of the logic to process packet list
|
||||
else:
|
||||
error_message = response.get('errorMessage', '无返回')
|
||||
Log(f'查询会员日合成失败: {error_message}')
|
||||
if '没有资格参与活动' in error_message:
|
||||
self.member_day_black = True
|
||||
Log('会员日任务风控')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def member_day_red_packet_merge(self, level):
|
||||
try:
|
||||
payload = {'level': level, 'num': 2}
|
||||
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~memberDayPacketService~redPacketMerge'
|
||||
|
||||
response = self.do_request(url, payload)
|
||||
if response.get('success'):
|
||||
Log(f'会员日合成: [{level}级]红包X2 -> [{level + 1}级]红包')
|
||||
self.member_day_red_packet_map[level] -= 2
|
||||
if not self.member_day_red_packet_map.get(level + 1):
|
||||
self.member_day_red_packet_map[level + 1] = 0
|
||||
self.member_day_red_packet_map[level + 1] += 1
|
||||
else:
|
||||
error_message = response.get('errorMessage', '无返回')
|
||||
Log(f'会员日合成两个[{level}级]红包失败: {error_message}')
|
||||
if '没有资格参与活动' in error_message:
|
||||
self.member_day_black = True
|
||||
Log('会员日任务风控')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def main(self):
|
||||
global one_msg
|
||||
wait_time = random.randint(1000, 3000) / 1000.0 # 转换为秒
|
||||
time.sleep(wait_time) # 等待
|
||||
one_msg = ''
|
||||
if not self.login_res:return False
|
||||
# 执行签到任务
|
||||
if not self.login_res: return False
|
||||
执行签到任务
|
||||
self.sign()
|
||||
self.superWelfare_receiveRedPacket()
|
||||
self.get_SignTaskList()
|
||||
@ -992,17 +1203,25 @@ class RUN:
|
||||
#获取任务列表并执行任务
|
||||
self.get_honeyTaskListStart()
|
||||
self.honey_indexData(True)
|
||||
#######################################
|
||||
# # 获取当前季度结束日期
|
||||
# activity_end_date = get_quarter_end_date()
|
||||
# if is_activity_end_date(activity_end_date):
|
||||
# Log("今天采蜜活动截止兑换,请及时进行兑换")
|
||||
# send('顺丰速运挂机通知', "今天采蜜活动截止兑换,请及时进行兑换")
|
||||
target_time = datetime(2024, 4, 8, 19, 0)
|
||||
if datetime.now() < target_time:
|
||||
# self.EAR_END_2023_TaskList()
|
||||
self.anniversary2024_task()
|
||||
# target_time = datetime(2024, 4, 8, 19, 0)
|
||||
# if datetime.now() < target_time:
|
||||
# # self.EAR_END_2023_TaskList()
|
||||
# self.anniversary2024_task()
|
||||
# else:
|
||||
# print('周年庆活动已结束')
|
||||
#######################################
|
||||
self.member_day_index()
|
||||
current_date = datetime.now().day
|
||||
if 26 <= current_date <= 28:
|
||||
self.member_day_index()
|
||||
else:
|
||||
print('周年庆活动已结束')
|
||||
print('未到指定时间不执行会员日任务')
|
||||
self.sendMsg()
|
||||
return True
|
||||
|
||||
@ -1012,7 +1231,6 @@ class RUN:
|
||||
print(push_res)
|
||||
|
||||
|
||||
|
||||
def get_quarter_end_date():
|
||||
current_date = datetime.now()
|
||||
current_month = current_date.month
|
||||
@ -1026,6 +1244,7 @@ def get_quarter_end_date():
|
||||
|
||||
return quarter_end_date.strftime("%Y-%m-%d")
|
||||
|
||||
|
||||
def is_activity_end_date(end_date):
|
||||
current_date = datetime.now().date()
|
||||
end_date = datetime.strptime(end_date, "%Y-%m-%d").date()
|
||||
@ -1033,7 +1252,6 @@ def is_activity_end_date(end_date):
|
||||
return current_date == end_date
|
||||
|
||||
|
||||
|
||||
def down_file(filename, file_url):
|
||||
print(f'开始下载:{filename},下载地址:{file_url}')
|
||||
try:
|
||||
@ -1060,10 +1278,13 @@ def down_file(filename, file_url):
|
||||
print(f'【{filename}】下载失败:{str(e)}')
|
||||
return False
|
||||
|
||||
|
||||
def import_Tools():
|
||||
global CHERWIN_TOOLS,ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
|
||||
global CHERWIN_TOOLS, ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
|
||||
import CHERWIN_TOOLS
|
||||
ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode = CHERWIN_TOOLS.main(APP_NAME, local_script_name, ENV_NAME,local_version)
|
||||
ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode = CHERWIN_TOOLS.main(APP_NAME, local_script_name, ENV_NAME,
|
||||
local_version)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
APP_NAME = '顺丰速运'
|
||||
@ -1094,16 +1315,19 @@ export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
''')
|
||||
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.04.16'
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://py.cherwin.cn/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://py.cherwin.cn/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
@ -1118,4 +1342,3 @@ export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
run_result = RUN(infos, index).main()
|
||||
if not run_result: continue
|
||||
if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|
||||
|
||||
|
||||
56
TBHYZX.py
Normal file → Executable file
56
TBHYZX.py
Normal file → Executable file
@ -15,8 +15,10 @@ from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
#
|
||||
if os.path.isfile('/DEV_ENV.py'):
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
@ -36,8 +38,7 @@ class RUN:
|
||||
global one_msg
|
||||
one_msg = ''
|
||||
split_info = info.split('@')
|
||||
|
||||
self.token = split_info[0]
|
||||
self.token = json.loads(split_info[0])
|
||||
# print(self.token)
|
||||
len_split_info = len(split_info)
|
||||
last_info = split_info[len_split_info - 1]
|
||||
@ -69,6 +70,8 @@ class RUN:
|
||||
}
|
||||
#
|
||||
# print(self.headers)
|
||||
for key, value in self.token.items():
|
||||
self.headers[key] = value
|
||||
self.baseUrl = 'https://wxa-tp.ezrpro.com/myvip/'
|
||||
|
||||
|
||||
@ -120,17 +123,30 @@ class RUN:
|
||||
def WxAppOnLoginNew(self):
|
||||
Log('>>>>>>登陆')
|
||||
url = "https://wxa-tp.ezrpro.com/myvip/Base/User/WxAppOnLoginNew"
|
||||
# data = {
|
||||
# "code": self.token,
|
||||
# "CommonIdType": "VipWxUnionId",
|
||||
# "CommonId": "124948229",
|
||||
# "ShopId": 0,
|
||||
# "CommonIdSource": 47,
|
||||
# "Latitude": 0,
|
||||
# "Longitude": 0,
|
||||
# "InviteActObj": "{\"ActId\":50726}",
|
||||
# "PingId": "peLXqZCQAAD-C3PrZ36DkaE98NoLjuqQ",
|
||||
# # "PingDate": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
# "PingDate": '2024-03-19 22:23:01'
|
||||
# }
|
||||
data = {
|
||||
"code": self.token,
|
||||
"CommonIdType": "VipId",
|
||||
"CommonId": "124948229",
|
||||
"CommonIdType": "VipWxUnionId",
|
||||
"CommonId": "",
|
||||
"ShopId": 0,
|
||||
"CommonIdSource": 98,
|
||||
"CommonIdSource": 47,
|
||||
"Latitude": 0,
|
||||
"Longitude": 0,
|
||||
"InviteActObj": "{\"ActId\":50726}",
|
||||
"PingId": "peLXqZCQAA3W2G4d-pEZ8FRPEjxKdzoQ",
|
||||
"PingDate": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
"code": "0c1QVUFa1bogqH0W87Ga1ZHjjG3QVUFP",
|
||||
"PingId": "peLXqZCQAAD-C3PrZ36DkaE98NoLjuqQ",
|
||||
"PingDate": "2024-03-19 22:23:01"
|
||||
}
|
||||
response = s.post(url, headers=self.headers,json=data)
|
||||
response = response.json()
|
||||
@ -187,8 +203,9 @@ class RUN:
|
||||
|
||||
def main(self):
|
||||
Log(f"\n开始执行第{self.index}个账号--------------->>>>>")
|
||||
if self.WxAppOnLoginNew():
|
||||
self.GetVipCardInfoByVipId()
|
||||
# if self.WxAppOnLoginNew():
|
||||
if self.GetVipCardInfoByVipId():
|
||||
# self.GetVipCardInfoByVipId()
|
||||
self.GetSignInDtlInfo()
|
||||
self.BonusClassify()
|
||||
self.sendMsg()
|
||||
@ -261,16 +278,19 @@ export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.05.08'
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://py.cherwin.cn/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://py.cherwin.cn/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
@ -287,4 +307,4 @@ export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
s.verify = False
|
||||
run_result = RUN(infos, index).main()
|
||||
if not run_result: continue
|
||||
if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|
||||
if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|
||||
825
TYQH_JK.py
Normal file → Executable file
825
TYQH_JK.py
Normal file → Executable file
@ -1,426 +1,399 @@
|
||||
# !/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
# -------------------------------
|
||||
# @Author : cherwin
|
||||
# -------------------------------
|
||||
# cron "59 9 * 2-6 * *" script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('统一茄皇监控')
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import string
|
||||
import time
|
||||
from datetime import datetime
|
||||
from os import environ, path
|
||||
|
||||
import requests
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
else:
|
||||
print("加载通知服务失败!")
|
||||
send_msg = ''
|
||||
one_msg=''
|
||||
def Log(cont=''):
|
||||
global send_msg,one_msg
|
||||
print(cont)
|
||||
if cont:
|
||||
one_msg += f'{cont}\n'
|
||||
send_msg += f'{cont}\n'
|
||||
|
||||
USER_INFO = {}
|
||||
|
||||
class RUN:
|
||||
def __init__(self, info,index):
|
||||
global one_msg
|
||||
one_msg = ''
|
||||
split_info = info.split('@')
|
||||
self.third_id = split_info[0]
|
||||
self.wid = split_info[1]
|
||||
len_split_info = len(split_info)
|
||||
last_info = split_info[len_split_info - 1]
|
||||
self.send_UID = None
|
||||
if len_split_info > 0 and "UID_" in last_info:
|
||||
self.send_UID = last_info
|
||||
|
||||
self.user_index = index + 1
|
||||
print(f"\n---------开始执行第{self.user_index}个账号>>>>>")
|
||||
self.s = requests.session()
|
||||
self.s.verify = False
|
||||
|
||||
self.UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x6309080f) XWEB/8555'
|
||||
|
||||
self.headers = {
|
||||
'User-Agent': self.UA,
|
||||
'Sec-Fetch-Site': 'cross-site',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9',
|
||||
'Origin': 'https://thekingoftomato.ioutu.cn',
|
||||
'Referer': 'https://thekingoftomato.ioutu.cn/'
|
||||
|
||||
}
|
||||
self.base_url = 'https://qiehuang-apig.xiaoyisz.com/qiehuangsecond/ga'
|
||||
self.goodsid = None
|
||||
self.Login_res = self.login()
|
||||
|
||||
def load_json(self):
|
||||
try:
|
||||
with open(f"INVITE_CODE/{ENV_NAME}_INVITE_CODE.json", 'r', encoding='utf-8') as file:
|
||||
data = json.load(file)
|
||||
return data
|
||||
except FileNotFoundError:
|
||||
print("未找到文件,返回空字典")
|
||||
return {}
|
||||
except Exception as e:
|
||||
print(f"发生错误:{e}")
|
||||
return {}
|
||||
|
||||
def make_request(self, url, method='post', headers={}, params={}):
|
||||
if headers == {}:
|
||||
headers = self.headers
|
||||
if params == {}:
|
||||
params = self.params
|
||||
try:
|
||||
if method.lower() == 'get':
|
||||
response = requests.get(url, headers=headers, verify=False)
|
||||
|
||||
elif method.lower() == 'post':
|
||||
response = requests.post(url, headers=headers, json=params, verify=False)
|
||||
else:
|
||||
raise ValueError("不支持的请求方法: " + method)
|
||||
return response.json()
|
||||
except requests.exceptions.RequestException as e:
|
||||
print("请求异常:", e)
|
||||
except ValueError as e:
|
||||
print("值错误或不支持的请求方法:", e)
|
||||
except Exception as e:
|
||||
print("发生了未知错误:", e)
|
||||
|
||||
def gen_sign(self, parameters={}, body=None):
|
||||
sorted_keys = sorted(parameters.keys())
|
||||
parameter_strings = []
|
||||
for key in sorted_keys:
|
||||
if isinstance(parameters[key], dict):
|
||||
parameter_strings.append(f"{key}={json.dumps(parameters[key])}")
|
||||
else:
|
||||
parameter_strings.append(f"{key}={parameters[key]}")
|
||||
|
||||
current_time = int(datetime.now().timestamp() * 1000)
|
||||
secret_chars = list('BxzTx45uIGT25TTHIIBU2')
|
||||
last_three_digits = str(current_time)[-3:]
|
||||
for digit in last_three_digits:
|
||||
secret_chars.insert(int(digit), digit)
|
||||
|
||||
secret = hashlib.md5(''.join(secret_chars).encode()).hexdigest()
|
||||
nonce_str = ''.join(random.choices(string.ascii_letters + string.digits, k=16))
|
||||
|
||||
sign_data = {
|
||||
'client_id': 'game',
|
||||
'nonstr': nonce_str,
|
||||
'timestamp': current_time,
|
||||
'body': json.dumps(body) if body else '',
|
||||
'query': '&'.join(parameter_strings) if parameter_strings else '',
|
||||
'secret': secret
|
||||
}
|
||||
|
||||
sign_string = '|'.join([str(v) for v in sign_data.values()])
|
||||
sign = hashlib.md5(sign_string.encode()).hexdigest().upper()
|
||||
sign_header = {
|
||||
'client_id': 'game',
|
||||
'timestamp': str(current_time),
|
||||
'nonstr': sign_data['nonstr'],
|
||||
'sign': sign
|
||||
}
|
||||
self.headers.update(sign_header)
|
||||
return self.headers
|
||||
|
||||
def login(self):
|
||||
login_successful = False
|
||||
try:
|
||||
login_params = {
|
||||
'thirdId': self.third_id,
|
||||
'wid': self.wid
|
||||
}
|
||||
sign_header = self.gen_sign({}, login_params)
|
||||
# print(self.headers)
|
||||
# Hypothetically speaking, this is how you might perform a POST request in Python with the requests library.
|
||||
response = self.s.post(f'{self.base_url}/public/api/login', json=login_params, headers=sign_header)
|
||||
if response.status_code == 200:
|
||||
response_data = response.json()
|
||||
if response_data.get('code', -1) == 0:
|
||||
auth = response_data['data']['token'] or ''
|
||||
if auth:
|
||||
login_successful = True
|
||||
print(f'账号【{self.user_index}】登录成功')
|
||||
Authorization = {'Authorization': auth}
|
||||
self.headers.update(Authorization)
|
||||
else:
|
||||
print(f'账号【{self.user_index}】登录获取auth失败')
|
||||
else:
|
||||
print(f"登录获取auth失败[{response_data['code']}]: {response_data['message']}")
|
||||
elif response.status_code == 403:
|
||||
print('登录失败[403]: 黑IP了, 换个IP试试吧')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
finally:
|
||||
return login_successful
|
||||
|
||||
def get_CapCode(self, slideImgInfo):
|
||||
slidingImage = slideImgInfo.get('slidingImage', None)
|
||||
backImage = slideImgInfo.get('backImage', None)
|
||||
dddddocr_api = os.environ.get('OCR_API',False)
|
||||
if not dddddocr_api:
|
||||
print('未定义变量【OCR_API】\n取消验证码识别\n搭建方式:https://github.com/CHERWING/CHERWIN_SCRIPTS')
|
||||
return False
|
||||
if slidingImage and backImage:
|
||||
data = {
|
||||
"slidingImage": slidingImage,
|
||||
"backImage": backImage
|
||||
}
|
||||
response = requests.post(f"{dddddocr_api}/capcode", data=json.dumps(data),headers={'Content-Type': 'application/json'})
|
||||
print(response.json())
|
||||
self.capcode = response.json().get('result','')
|
||||
if self.capcode:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_CapCode_local(self, slideImgInfo):
|
||||
slidingImage = slideImgInfo.get('slidingImage', None)
|
||||
backImage = slideImgInfo.get('backImage', None)
|
||||
if slidingImage and backImage:
|
||||
self.capcode =CHERWIN_TOOLS.CAPCODE(slidingImage,backImage)
|
||||
if self.capcode:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def checkUserCapCode(self):
|
||||
print(f'提交验证码--->>>')
|
||||
# try:
|
||||
print(f'验证码:{self.capcode}')
|
||||
params = {'xpos':self.capcode}
|
||||
print(params)
|
||||
sign_header = self.gen_sign(body=params)
|
||||
url = f'{self.base_url}/checkUserCapCode'
|
||||
response = self.s.post(url, headers=sign_header, json=params)
|
||||
data = response.json()
|
||||
code = data.get('code', -1)
|
||||
if code == 0:
|
||||
data = data.get('data', 0)
|
||||
print(f"验证码正确,获取到[{data}]")
|
||||
return True
|
||||
else:
|
||||
message = data.get('message', '')
|
||||
print(f"验证码错误[{message}]")
|
||||
return False
|
||||
# except Exception as e:
|
||||
# print(e)
|
||||
|
||||
def exchange_find(self):
|
||||
print(f'获取兑换列表--->>>')
|
||||
try:
|
||||
sign_header = self.gen_sign()
|
||||
url = f'{self.base_url}/exchange/find'
|
||||
response = self.s.get(url, headers=sign_header)
|
||||
data = response.json()
|
||||
code = data.get('code', -1)
|
||||
if code == 0:
|
||||
data = data.get('data', {})[1]
|
||||
num = data.get('num',0)
|
||||
if num < 0 :
|
||||
Log('兑换上限,跳过')
|
||||
return False
|
||||
# print(f"兑换列表:{data}")
|
||||
exchangePrizeVoList = data.get('exchangePrizeVoList',None)
|
||||
if exchangePrizeVoList:
|
||||
for goods in exchangePrizeVoList:
|
||||
name = goods.get('name','')
|
||||
self.goodsid = goods.get('id','')
|
||||
usableStock = goods.get('usableStock','')
|
||||
if usableStock >0:
|
||||
Log(f'ID:【{self.goodsid}】 【{name}】 当前剩余:{usableStock}【可兑换】')
|
||||
self.sendMsg()
|
||||
if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|
||||
if TYQH_DHID and TYQH_DHID == self.goodsid:
|
||||
self.exchange_reward(TYQH_DHID)
|
||||
elif TYQH_DHID == '0':
|
||||
self.exchange_reward(self.goodsid)
|
||||
else:
|
||||
continue
|
||||
else:
|
||||
print(f'ID:【{self.goodsid}】【{name}】 当前剩余:{usableStock}【不可兑换】')
|
||||
else:
|
||||
message = data.get('message', '')
|
||||
print(f'{message}')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def exchange_reward(self, reward_id):
|
||||
print(f'尝试兑换--->>>')
|
||||
try:
|
||||
params = {'id': reward_id}
|
||||
sign_header = self.gen_sign(params)
|
||||
url = f'{self.base_url}/exchange/reward'
|
||||
response = self.s.get(url, headers=sign_header, params=params)
|
||||
data = response.json()
|
||||
code = data.get('code', -1)
|
||||
if code == 0:
|
||||
data = data.get('data', {}).get('name') or ''
|
||||
Log(f"兑换[{data}]成功")
|
||||
elif code == 4000:
|
||||
slideImgInfo = data.get('data', {}).get('slideImgInfo', None)
|
||||
validateCount = data.get('data', {}).get('validateCount', None)
|
||||
if slideImgInfo and validateCount:
|
||||
print(f"兑换需要滑块验证")
|
||||
if self.get_CapCode(slideImgInfo):
|
||||
if self.checkUserCapCode():
|
||||
self.exchange_reward(reward_id)
|
||||
else:
|
||||
print(f"兑换验证码上限")
|
||||
else:
|
||||
message = data.get('message', '')
|
||||
print(f'兑换[id={reward_id}]: {message}')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def userTask(self):
|
||||
print('\n--------------- 开始日常任务 ---------------')
|
||||
wait_time = random.randint(1000, 3000) / 1000.0 # 转换为秒
|
||||
if not self.Login_res:
|
||||
return False
|
||||
self.exchange_find()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def sendMsg(self, help=False):
|
||||
if self.send_UID:
|
||||
push_res = CHERWIN_TOOLS.wxpusher(self.send_UID, one_msg, APP_NAME, help)
|
||||
print(push_res)
|
||||
|
||||
|
||||
def down_file(filename, file_url):
|
||||
print(f'开始下载:{filename},下载地址:{file_url}')
|
||||
try:
|
||||
response = requests.get(file_url, verify=False, timeout=10)
|
||||
response.raise_for_status()
|
||||
with open(filename + '.tmp', 'wb') as f:
|
||||
f.write(response.content)
|
||||
print(f'【{filename}】下载完成!')
|
||||
|
||||
# 检查临时文件是否存在
|
||||
temp_filename = filename + '.tmp'
|
||||
if os.path.exists(temp_filename):
|
||||
# 删除原有文件
|
||||
if os.path.exists(filename):
|
||||
os.remove(filename)
|
||||
# 重命名临时文件
|
||||
os.rename(temp_filename, filename)
|
||||
print(f'【{filename}】重命名成功!')
|
||||
return True
|
||||
else:
|
||||
print(f'【{filename}】临时文件不存在!')
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f'【{filename}】下载失败:{str(e)}')
|
||||
return False
|
||||
|
||||
def import_Tools():
|
||||
global CHERWIN_TOOLS,ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
|
||||
import CHERWIN_TOOLS
|
||||
ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode = CHERWIN_TOOLS.main(APP_NAME, local_script_name, ENV_NAME,local_version)
|
||||
import threading
|
||||
|
||||
def execute_task(infos, index):
|
||||
run_result = RUN(infos, index).userTask()
|
||||
if not run_result:
|
||||
return
|
||||
|
||||
if __name__ == '__main__':
|
||||
APP_NAME = '统一茄皇监控'
|
||||
ENV_NAME = 'TYQH_JK'
|
||||
print(f'''
|
||||
✨✨✨ {APP_NAME}脚本 ✨✨✨
|
||||
✨ 功能:
|
||||
奖品监控
|
||||
✨ 设置青龙变量:
|
||||
export TYQH= '' 使用相同TYQH变量
|
||||
export TYQH_DHID= '112' 设置兑换ID则开启自动兑换,设置为0遍历兑换全部可兑换商品
|
||||
export OCR_API= 'http://localhost:3721'
|
||||
✨ 由于青龙python版本问题无法直接使用dddocr需要自行搭建API,搭建方式:https://github.com/CHERWING/CHERWIN_OCR
|
||||
✨ 如果你的环境可以安装dddocr库则可以替换代码内的【self.get_CapCode】为【self.get_CapCode_local】
|
||||
export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨ 推荐定时:*/10 9:59 1-31 2-6 * * 2-6月每月1日9点55到10点1分,每10秒执行一次
|
||||
✨ 第一个账号助力作者,其余互助
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.05.04'
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://py.cherwin.cn/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://py.cherwin.cn/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
ENV = os.environ.get('TYQH','')
|
||||
TYQH_DHID = os.environ.get('TYQH_DHID',None)
|
||||
if TYQH_DHID == '0':
|
||||
Log(f'\n当前已设置TYQH_DHID变量,将自动遍历兑换商品')
|
||||
elif TYQH_DHID:
|
||||
Log(f'\n当前已设置TYQH_DHID变量,将自动兑换id【{TYQH_DHID}】商品')
|
||||
else:
|
||||
Log('\n未定义TYQH_DHID变量,取消自动兑换')
|
||||
token = ENV if ENV else token
|
||||
if not token:
|
||||
print(f"未填写TYQH变量\n青龙可在环境变量设置TYQH 或者在本脚本文件上方将ck填入token =''")
|
||||
exit()
|
||||
tokens = CHERWIN_TOOLS.ENV_SPLIT(token)
|
||||
# print(tokens)
|
||||
if len(tokens) > 0:
|
||||
print(f"\n>>>>>>>>>> 共获取到{len(tokens)} 个账号 <<<<<<<<<<")
|
||||
# access_token = []
|
||||
# threads = []
|
||||
# for index, infos in enumerate(tokens):
|
||||
# thread = threading.Thread(target=execute_task, args=(infos, index))
|
||||
# threads.append(thread)
|
||||
# thread.start()
|
||||
#
|
||||
# for thread in threads:
|
||||
# thread.join()
|
||||
while True:
|
||||
current_time = time.localtime()
|
||||
if (current_time.tm_hour == 9 and current_time.tm_min == 59 and current_time.tm_sec >= 59) or \
|
||||
(current_time.tm_hour == 10 and current_time.tm_min == 1 and current_time.tm_sec <= 59):
|
||||
if len(tokens) > 0:
|
||||
print(f"\n>>>>>>>>>> 共获取到{len(tokens)} 个账号 <<<<<<<<<<")
|
||||
access_token = []
|
||||
threads = []
|
||||
for index, infos in enumerate(tokens):
|
||||
thread = threading.Thread(target=execute_task, args=(infos, index))
|
||||
threads.append(thread)
|
||||
thread.start()
|
||||
|
||||
for thread in threads:
|
||||
thread.join()
|
||||
elif current_time.tm_hour == 10 and current_time.tm_min > 5:
|
||||
break
|
||||
else:
|
||||
time.sleep(1)
|
||||
|
||||
# !/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
# -------------------------------
|
||||
# @Author : cherwin
|
||||
# -------------------------------
|
||||
# cron "59 9 * 2-6 * *" script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('统一茄皇监控')
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import string
|
||||
import time
|
||||
from datetime import datetime
|
||||
from os import environ, path
|
||||
|
||||
import requests
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
else:
|
||||
print("加载通知服务失败!")
|
||||
send_msg = ''
|
||||
one_msg=''
|
||||
def Log(cont=''):
|
||||
global send_msg,one_msg
|
||||
print(cont)
|
||||
if cont:
|
||||
one_msg += f'{cont}\n'
|
||||
send_msg += f'{cont}\n'
|
||||
|
||||
USER_INFO = {}
|
||||
|
||||
class RUN:
|
||||
def __init__(self, info,index):
|
||||
global one_msg
|
||||
one_msg = ''
|
||||
split_info = info.split('@')
|
||||
self.third_id = split_info[0]
|
||||
self.wid = split_info[1]
|
||||
len_split_info = len(split_info)
|
||||
last_info = split_info[len_split_info - 1]
|
||||
self.send_UID = None
|
||||
if len_split_info > 0 and "UID_" in last_info:
|
||||
self.send_UID = last_info
|
||||
|
||||
self.user_index = index + 1
|
||||
print(f"\n---------开始执行第{self.user_index}个账号>>>>>")
|
||||
self.s = requests.session()
|
||||
self.s.verify = False
|
||||
|
||||
self.UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x6309080f) XWEB/8555'
|
||||
|
||||
self.headers = {
|
||||
'User-Agent': self.UA,
|
||||
'Sec-Fetch-Site': 'cross-site',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9',
|
||||
'Origin': 'https://thekingoftomato.ioutu.cn',
|
||||
'Referer': 'https://thekingoftomato.ioutu.cn/'
|
||||
|
||||
}
|
||||
self.base_url = 'https://qiehuang-apig.xiaoyisz.com/qiehuangsecond/ga'
|
||||
self.goodsid = None
|
||||
self.Login_res = self.login()
|
||||
|
||||
def load_json(self):
|
||||
try:
|
||||
with open(f"INVITE_CODE/{ENV_NAME}_INVITE_CODE.json", 'r', encoding='utf-8') as file:
|
||||
data = json.load(file)
|
||||
return data
|
||||
except FileNotFoundError:
|
||||
print("未找到文件,返回空字典")
|
||||
return {}
|
||||
except Exception as e:
|
||||
print(f"发生错误:{e}")
|
||||
return {}
|
||||
|
||||
def make_request(self, url, method='post', headers={}, params={}):
|
||||
if headers == {}:
|
||||
headers = self.headers
|
||||
if params == {}:
|
||||
params = self.params
|
||||
try:
|
||||
if method.lower() == 'get':
|
||||
response = requests.get(url, headers=headers, verify=False)
|
||||
|
||||
elif method.lower() == 'post':
|
||||
response = requests.post(url, headers=headers, json=params, verify=False)
|
||||
else:
|
||||
raise ValueError("不支持的请求方法: " + method)
|
||||
return response.json()
|
||||
except requests.exceptions.RequestException as e:
|
||||
print("请求异常:", e)
|
||||
except ValueError as e:
|
||||
print("值错误或不支持的请求方法:", e)
|
||||
except Exception as e:
|
||||
print("发生了未知错误:", e)
|
||||
|
||||
def gen_sign(self, parameters={}, body=None):
|
||||
sign_header=CHERWIN_TOOLS.TYQH_SIGN(parameters,body)
|
||||
self.headers.update(sign_header)
|
||||
return self.headers
|
||||
|
||||
def login(self):
|
||||
login_successful = False
|
||||
try:
|
||||
login_params = {
|
||||
'thirdId': self.third_id,
|
||||
'wid': self.wid
|
||||
}
|
||||
sign_header = self.gen_sign({}, login_params)
|
||||
# print(self.headers)
|
||||
# Hypothetically speaking, this is how you might perform a POST request in Python with the requests library.
|
||||
response = self.s.post(f'{self.base_url}/public/api/login', json=login_params, headers=sign_header)
|
||||
if response.status_code == 200:
|
||||
response_data = response.json()
|
||||
if response_data.get('code', -1) == 0:
|
||||
auth = response_data['data']['token'] or ''
|
||||
if auth:
|
||||
login_successful = True
|
||||
print(f'账号【{self.user_index}】登录成功')
|
||||
Authorization = {'Authorization': auth}
|
||||
self.headers.update(Authorization)
|
||||
else:
|
||||
print(f'账号【{self.user_index}】登录获取auth失败')
|
||||
else:
|
||||
print(f"登录获取auth失败[{response_data['code']}]: {response_data['message']}")
|
||||
elif response.status_code == 403:
|
||||
print('登录失败[403]: 黑IP了, 换个IP试试吧')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
finally:
|
||||
return login_successful
|
||||
|
||||
def get_CapCode(self, slideImgInfo):
|
||||
slidingImage = slideImgInfo.get('slidingImage', None)
|
||||
backImage = slideImgInfo.get('backImage', None)
|
||||
dddddocr_api = os.environ.get('OCR_API',False)
|
||||
if not dddddocr_api:
|
||||
print('未定义变量【OCR_API】\n取消验证码识别\n搭建方式:https://github.com/CHERWING/CHERWIN_SCRIPTS')
|
||||
return False
|
||||
if slidingImage and backImage:
|
||||
data = {
|
||||
"slidingImage": slidingImage,
|
||||
"backImage": backImage
|
||||
}
|
||||
response = requests.post(f"{dddddocr_api}/capcode", data=json.dumps(data),headers={'Content-Type': 'application/json'})
|
||||
print(response.json())
|
||||
self.capcode = response.json().get('result','')
|
||||
if self.capcode:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_CapCode_local(self, slideImgInfo):
|
||||
slidingImage = slideImgInfo.get('slidingImage', None)
|
||||
backImage = slideImgInfo.get('backImage', None)
|
||||
if slidingImage and backImage:
|
||||
self.capcode =CHERWIN_TOOLS.CAPCODE(slidingImage,backImage)
|
||||
if self.capcode:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def checkUserCapCode(self):
|
||||
print(f'提交验证码--->>>')
|
||||
# try:
|
||||
print(f'验证码:{self.capcode}')
|
||||
params = {'xpos':self.capcode}
|
||||
print(params)
|
||||
sign_header = self.gen_sign(body=params)
|
||||
url = f'{self.base_url}/checkUserCapCode'
|
||||
response = self.s.post(url, headers=sign_header, json=params)
|
||||
data = response.json()
|
||||
code = data.get('code', -1)
|
||||
if code == 0:
|
||||
data = data.get('data', 0)
|
||||
print(f"验证码正确,获取到[{data}]")
|
||||
return True
|
||||
else:
|
||||
message = data.get('message', '')
|
||||
print(f"验证码错误[{message}]")
|
||||
return False
|
||||
# except Exception as e:
|
||||
# print(e)
|
||||
|
||||
def exchange_find(self):
|
||||
print(f'获取兑换列表--->>>')
|
||||
try:
|
||||
sign_header = self.gen_sign()
|
||||
url = f'{self.base_url}/exchange/find'
|
||||
response = self.s.get(url, headers=sign_header)
|
||||
data = response.json()
|
||||
code = data.get('code', -1)
|
||||
if code == 0:
|
||||
data = data.get('data', {})[1]
|
||||
num = data.get('num',0)
|
||||
if num < 0 :
|
||||
Log('兑换上限,跳过')
|
||||
return False
|
||||
# print(f"兑换列表:{data}")
|
||||
exchangePrizeVoList = data.get('exchangePrizeVoList',None)
|
||||
if exchangePrizeVoList:
|
||||
for goods in exchangePrizeVoList:
|
||||
name = goods.get('name','')
|
||||
self.goodsid = goods.get('id','')
|
||||
usableStock = goods.get('usableStock','')
|
||||
if usableStock >0:
|
||||
Log(f'ID:【{self.goodsid}】 【{name}】 当前剩余:{usableStock}【可兑换】')
|
||||
self.sendMsg()
|
||||
if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|
||||
if TYQH_DHID and TYQH_DHID == self.goodsid:
|
||||
self.exchange_reward(TYQH_DHID)
|
||||
elif TYQH_DHID == '0':
|
||||
self.exchange_reward(self.goodsid)
|
||||
else:
|
||||
continue
|
||||
else:
|
||||
print(f'ID:【{self.goodsid}】【{name}】 当前剩余:{usableStock}【不可兑换】')
|
||||
else:
|
||||
message = data.get('message', '')
|
||||
print(f'{message}')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def exchange_reward(self, reward_id):
|
||||
print(f'尝试兑换--->>>')
|
||||
try:
|
||||
params = {'id': reward_id}
|
||||
sign_header = self.gen_sign(params)
|
||||
url = f'{self.base_url}/exchange/reward'
|
||||
response = self.s.get(url, headers=sign_header, params=params)
|
||||
data = response.json()
|
||||
code = data.get('code', -1)
|
||||
if code == 0:
|
||||
data = data.get('data', {}).get('name') or ''
|
||||
Log(f"兑换[{data}]成功")
|
||||
elif code == 4000:
|
||||
slideImgInfo = data.get('data', {}).get('slideImgInfo', None)
|
||||
validateCount = data.get('data', {}).get('validateCount', None)
|
||||
if slideImgInfo and validateCount:
|
||||
print(f"兑换需要滑块验证")
|
||||
if self.get_CapCode(slideImgInfo):
|
||||
if self.checkUserCapCode():
|
||||
self.exchange_reward(reward_id)
|
||||
else:
|
||||
print(f"兑换验证码上限")
|
||||
else:
|
||||
message = data.get('message', '')
|
||||
print(f'兑换[id={reward_id}]: {message}')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def userTask(self):
|
||||
print('\n--------------- 开始日常任务 ---------------')
|
||||
wait_time = random.randint(1000, 3000) / 1000.0 # 转换为秒
|
||||
if not self.Login_res:
|
||||
return False
|
||||
self.exchange_find()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def sendMsg(self, help=False):
|
||||
if self.send_UID:
|
||||
push_res = CHERWIN_TOOLS.wxpusher(self.send_UID, one_msg, APP_NAME, help)
|
||||
print(push_res)
|
||||
|
||||
|
||||
def down_file(filename, file_url):
|
||||
print(f'开始下载:{filename},下载地址:{file_url}')
|
||||
try:
|
||||
response = requests.get(file_url, verify=False, timeout=10)
|
||||
response.raise_for_status()
|
||||
with open(filename + '.tmp', 'wb') as f:
|
||||
f.write(response.content)
|
||||
print(f'【{filename}】下载完成!')
|
||||
|
||||
# 检查临时文件是否存在
|
||||
temp_filename = filename + '.tmp'
|
||||
if os.path.exists(temp_filename):
|
||||
# 删除原有文件
|
||||
if os.path.exists(filename):
|
||||
os.remove(filename)
|
||||
# 重命名临时文件
|
||||
os.rename(temp_filename, filename)
|
||||
print(f'【{filename}】重命名成功!')
|
||||
return True
|
||||
else:
|
||||
print(f'【{filename}】临时文件不存在!')
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f'【{filename}】下载失败:{str(e)}')
|
||||
return False
|
||||
|
||||
def import_Tools():
|
||||
global CHERWIN_TOOLS,ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
|
||||
import CHERWIN_TOOLS
|
||||
ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode = CHERWIN_TOOLS.main(APP_NAME, local_script_name, ENV_NAME,local_version)
|
||||
import threading
|
||||
|
||||
def execute_task(infos, index):
|
||||
run_result = RUN(infos, index).userTask()
|
||||
if not run_result:
|
||||
return
|
||||
|
||||
if __name__ == '__main__':
|
||||
APP_NAME = '统一茄皇监控'
|
||||
ENV_NAME = 'TYQH_JK'
|
||||
print(f'''
|
||||
✨✨✨ {APP_NAME}脚本 ✨✨✨
|
||||
✨ 功能:
|
||||
奖品监控
|
||||
✨ 设置青龙变量:
|
||||
export TYQH= '' 使用相同TYQH变量
|
||||
export TYQH_DHID= '112' 设置兑换ID则开启自动兑换,设置为0遍历兑换全部可兑换商品
|
||||
export OCR_API= 'http://localhost:3721'
|
||||
✨ 由于青龙python版本问题无法直接使用dddocr需要自行搭建API,搭建方式:https://github.com/CHERWING/CHERWIN_OCR
|
||||
✨ 如果你的环境可以安装dddocr库则可以替换代码内的【self.get_CapCode】为【self.get_CapCode_local】
|
||||
export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨ 推荐定时:*/10 9:59 1-31 2-6 * * 2-6月每月1日9点55到10点1分,每10秒执行一次
|
||||
✨ 第一个账号助力作者,其余互助
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print(
|
||||
'脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
ENV = os.environ.get('TYQH','')
|
||||
TYQH_DHID = os.environ.get('TYQH_DHID',None)
|
||||
if TYQH_DHID == '0':
|
||||
Log(f'\n当前已设置TYQH_DHID变量,将自动遍历兑换商品')
|
||||
elif TYQH_DHID:
|
||||
Log(f'\n当前已设置TYQH_DHID变量,将自动兑换id【{TYQH_DHID}】商品')
|
||||
else:
|
||||
Log('\n未定义TYQH_DHID变量,取消自动兑换')
|
||||
token = ENV if ENV else token
|
||||
if not token:
|
||||
print(f"未填写TYQH变量\n青龙可在环境变量设置TYQH 或者在本脚本文件上方将ck填入token =''")
|
||||
exit()
|
||||
tokens = CHERWIN_TOOLS.ENV_SPLIT(token)
|
||||
# print(tokens)
|
||||
if len(tokens) > 0:
|
||||
print(f"\n>>>>>>>>>> 共获取到{len(tokens)} 个账号 <<<<<<<<<<")
|
||||
# access_token = []
|
||||
# threads = []
|
||||
# for index, infos in enumerate(tokens):
|
||||
# thread = threading.Thread(target=execute_task, args=(infos, index))
|
||||
# threads.append(thread)
|
||||
# thread.start()
|
||||
#
|
||||
# for thread in threads:
|
||||
# thread.join()
|
||||
while True:
|
||||
current_time = time.localtime()
|
||||
if (current_time.tm_hour == 9 and current_time.tm_min == 59 and current_time.tm_sec >= 59) or \
|
||||
(current_time.tm_hour == 10 and current_time.tm_min == 1 and current_time.tm_sec <= 59):
|
||||
if len(tokens) > 0:
|
||||
print(f"\n>>>>>>>>>> 共获取到{len(tokens)} 个账号 <<<<<<<<<<")
|
||||
access_token = []
|
||||
threads = []
|
||||
for index, infos in enumerate(tokens):
|
||||
thread = threading.Thread(target=execute_task, args=(infos, index))
|
||||
threads.append(thread)
|
||||
thread.start()
|
||||
|
||||
for thread in threads:
|
||||
thread.join()
|
||||
elif current_time.tm_hour == 10 and current_time.tm_min > 5:
|
||||
break
|
||||
else:
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
18
TYYP.py
18
TYYP.py
@ -16,8 +16,10 @@ from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# import CHERWIN_TOOLS
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
@ -251,16 +253,20 @@ export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.04.06'
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://py.cherwin.cn/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://py.cherwin.cn/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print(
|
||||
'脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
|
||||
18
YDKD.py
18
YDKD.py
@ -32,8 +32,10 @@ from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# import CHERWIN_TOOLS
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
IS_DEV = False
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
IS_DEV = True
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
print("加载通知服务成功!")
|
||||
@ -339,16 +341,20 @@ export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.04.06'
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://py.cherwin.cn/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://py.cherwin.cn/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print(
|
||||
'脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
|
||||
149
ZTKD.py
149
ZTKD.py
@ -1,56 +1,42 @@
|
||||
# !/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
# -------------------------------
|
||||
# ✨✨✨ 中通快递小程序签到✨✨✨
|
||||
# ✨ 功能:
|
||||
# 积分签到
|
||||
# ✨ 抓包步骤:
|
||||
# 打开中通快递小程序
|
||||
# 授权登陆
|
||||
# 打开抓包工具
|
||||
# 找URl请求头带[x-token或者token]
|
||||
# 复制里面的[x-token或者token]参数值
|
||||
# 参数示例:eyJhbGciOiJIUzUxMiJ9.eyJnZW5lcmF0ZVRpbWUixxxxxx
|
||||
# ✨ 设置青龙变量:
|
||||
# export YDKD='x-token或者token参数值'多账号#或&分割
|
||||
# export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
# ✨ ✨ 注意:抓完CK没事儿别打开小程序,重新打开小程序请重新抓包
|
||||
# ✨ 推荐cron:0 6 * * *
|
||||
# ✨✨✨ @Author CHERWIN✨✨✨
|
||||
# -------------------------------
|
||||
# cron "0 6 * * *" script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('中通快递小程序签到')
|
||||
import json
|
||||
|
||||
import os
|
||||
import random
|
||||
import time
|
||||
from datetime import datetime, date
|
||||
from os import path
|
||||
import requests
|
||||
import hashlib
|
||||
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# import CHERWIN_TOOLS
|
||||
|
||||
# 禁用安全请求警告
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
#
|
||||
if os.path.isfile('DEV_ENV.py'):
|
||||
import DEV_ENV
|
||||
|
||||
IS_DEV = True
|
||||
if os.path.isfile('notify.py'):
|
||||
from notify import send
|
||||
|
||||
print("加载通知服务成功!")
|
||||
else:
|
||||
print("加载通知服务失败!")
|
||||
send_msg = ''
|
||||
one_msg=''
|
||||
one_msg = ''
|
||||
|
||||
|
||||
def Log(cont=''):
|
||||
global send_msg,one_msg
|
||||
global send_msg, one_msg
|
||||
print(cont)
|
||||
if cont:
|
||||
one_msg += f'{cont}\n'
|
||||
send_msg += f'{cont}\n'
|
||||
|
||||
|
||||
class RUN:
|
||||
def __init__(self,info,index):
|
||||
def __init__(self, info, index):
|
||||
global one_msg
|
||||
one_msg = ''
|
||||
split_info = info.split('@')
|
||||
@ -83,18 +69,18 @@ class RUN:
|
||||
self.list_index = 0
|
||||
self.isFirstTask = True
|
||||
|
||||
def get_point(self,END=False):
|
||||
def get_point(self, END=False):
|
||||
Log('>>>>>>获取积分信息')
|
||||
json_data = {}
|
||||
response = s.post(f'{self.baseUrl}user/point/get', headers=self.headers,json=json_data)
|
||||
response = s.post(f'{self.baseUrl}user/point/get', headers=self.headers, json=json_data)
|
||||
point_info = response.json()
|
||||
# print(point_info)
|
||||
code = point_info.get('code',-1)
|
||||
if point_info.get('success',False) == True and code == 10000:
|
||||
data = point_info.get('data',[{}])
|
||||
point=data.get('point',0)
|
||||
mobile=data.get('mobile','')
|
||||
mobile=mobile[:3] + "*" * 4 + mobile[7:]
|
||||
code = point_info.get('code', -1)
|
||||
if point_info.get('success', False) == True and code == 10000:
|
||||
data = point_info.get('data', [{}])
|
||||
point = data.get('point', 0)
|
||||
mobile = data.get('mobile', '')
|
||||
mobile = mobile[:3] + "*" * 4 + mobile[7:]
|
||||
if END:
|
||||
Log(f'>>执行后积分:【{point}】')
|
||||
else:
|
||||
@ -106,43 +92,42 @@ class RUN:
|
||||
return False
|
||||
|
||||
def Check_sign(self):
|
||||
Log('>>>>>>查询签到')
|
||||
json_data = {"calendarType":0}
|
||||
response = s.post(f'{self.baseUrl}member/sign/v2/calendar', headers=self.headers,json=json_data)
|
||||
response = response.json()
|
||||
# print(point_info)
|
||||
code = response.get('code', -1)
|
||||
if response['success']== True and response['data'] != None and code == 10000:
|
||||
data=response.get('data',{})
|
||||
dayList=data.get('dayList',[{}])
|
||||
signDays=data.get('signDays',0)
|
||||
for day in dayList:
|
||||
dates = day.get('date','')
|
||||
point = day.get('point','')
|
||||
signFlag = day.get('signFlag','')
|
||||
current_date = date.today()
|
||||
parsed_date = datetime.strptime(dates, '%Y-%m-%d').date()
|
||||
if parsed_date == current_date:
|
||||
if signFlag == 1:
|
||||
Log(f'>>今日已签到,连续签到【{signDays}】天,获得【{point}】积分')
|
||||
else:
|
||||
self.sign()
|
||||
else:
|
||||
Log(f"查询签到失败,{response['msg']}")
|
||||
Log('>>>>>>查询签到')
|
||||
json_data = {"calendarType": 0}
|
||||
response = s.post(f'{self.baseUrl}member/sign/v2/calendar', headers=self.headers, json=json_data)
|
||||
response = response.json()
|
||||
# print(point_info)
|
||||
code = response.get('code', -1)
|
||||
if response['success'] == True and response['data'] != None and code == 10000:
|
||||
data = response.get('data', {})
|
||||
dayList = data.get('dayList', [{}])
|
||||
signDays = data.get('signDays', 0)
|
||||
for day in dayList:
|
||||
dates = day.get('date', '')
|
||||
point = day.get('point', '')
|
||||
signFlag = day.get('signFlag', '')
|
||||
current_date = date.today()
|
||||
parsed_date = datetime.strptime(dates, '%Y-%m-%d').date()
|
||||
if parsed_date == current_date:
|
||||
if signFlag == 1:
|
||||
Log(f'>>今日已签到,连续签到【{signDays}】天,获得【{point}】积分')
|
||||
else:
|
||||
self.sign()
|
||||
else:
|
||||
Log(f"查询签到失败,{response['msg']}")
|
||||
|
||||
def sign(self):
|
||||
Log('>>>签到')
|
||||
json_data = {}
|
||||
response = s.post(f'{self.baseUrl}member/sign/v2/userSignIn', headers=self.headers,json=json_data)
|
||||
point_info = response.json()
|
||||
# print(point_info)
|
||||
code = point_info.get('code', -1)
|
||||
if point_info['success']== True and point_info['data'] != None and code == 10000:
|
||||
point=point_info['data']['point']
|
||||
Log(f'>>签到成功获得:【{point}】积分')
|
||||
else:
|
||||
Log(f">>签到失败,{point_info['msg']}")
|
||||
|
||||
|
||||
Log('>>>签到')
|
||||
json_data = {}
|
||||
response = s.post(f'{self.baseUrl}member/sign/v2/userSignIn', headers=self.headers, json=json_data)
|
||||
point_info = response.json()
|
||||
# print(point_info)
|
||||
code = point_info.get('code', -1)
|
||||
if point_info['success'] == True and point_info['data'] != None and code == 10000:
|
||||
point = point_info['data']['point']
|
||||
Log(f'>>签到成功获得:【{point}】积分')
|
||||
else:
|
||||
Log(f">>签到失败,{point_info['msg']}")
|
||||
|
||||
def main(self):
|
||||
print(f"\n开始执行第{self.index}个账号--------------->>>>>")
|
||||
@ -186,15 +171,17 @@ def down_file(filename, file_url):
|
||||
print(f'【{filename}】下载失败:{str(e)}')
|
||||
return False
|
||||
|
||||
|
||||
def import_Tools():
|
||||
global CHERWIN_TOOLS,ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
|
||||
global CHERWIN_TOOLS, ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
|
||||
import CHERWIN_TOOLS
|
||||
ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode = CHERWIN_TOOLS.main(APP_NAME, local_script_name, ENV_NAME,local_version)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
APP_NAME = '中通快递小程序'
|
||||
ENV_NAME = 'ZTKD'
|
||||
CK_NAME = 'x-token或者token'
|
||||
CK_NAME = 'token'
|
||||
print(f'''
|
||||
✨✨✨ {APP_NAME}签到✨✨✨
|
||||
✨ 功能:
|
||||
@ -203,7 +190,7 @@ if __name__ == '__main__':
|
||||
打开{APP_NAME}
|
||||
授权登陆
|
||||
打开抓包工具
|
||||
找URl请求头带[{CK_NAME}]
|
||||
找https://api.ztomember.com/api/user/point/get请求头里的[{CK_NAME}]
|
||||
复制里面的[{CK_NAME}]参数值
|
||||
参数示例:eyJhbGciOiJIUzUxMiJ9.eyJnZW5lcmF0ZVRpbWUixxxxxx
|
||||
✨ 设置青龙变量:
|
||||
@ -214,16 +201,20 @@ export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||||
✨✨✨ @Author CHERWIN✨✨✨
|
||||
''')
|
||||
local_script_name = os.path.basename(__file__)
|
||||
local_version = '2024.05.08'
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
local_version = '2024.05.15'
|
||||
if IS_DEV:
|
||||
import_Tools()
|
||||
else:
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://py.cherwin.cn/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||||
import_Tools()
|
||||
else:
|
||||
print('脚本依赖下载失败,请到https://py.cherwin.cn/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||||
print('脚本依赖下载完成请重新运行脚本')
|
||||
import_Tools()
|
||||
else:
|
||||
print(
|
||||
'脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||||
exit()
|
||||
print(TIPS)
|
||||
token = ''
|
||||
token = ENV if ENV else token
|
||||
|
||||
Loading…
Reference in New Issue
Block a user