diff --git a/Points_Based/JKHZ_QD.py b/Points_Based/JKHZ_QD.py new file mode 100644 index 0000000..3787bf4 --- /dev/null +++ b/Points_Based/JKHZ_QD.py @@ -0,0 +1,86 @@ +# const $ = new Env("接口盒子签到"); +# cron: 55 6 * * * +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import os +import sys +import json +import time +import requests +from datetime import datetime + +# ========== 配置区 ========== +SOURCE = 'env' # 从环境变量 HZ_API 读取(换行分割) +LOG_FILE = 'sign.log' +# ============================ + +def get_accounts(): + env = os.environ.get('HZ_API') + if not env: + print("❌ 未设置环境变量 HZ_API") + sys.exit(1) + accounts = [] + for line in env.splitlines(): + line = line.strip() + if not line or line.startswith('#'): + continue + if '#' in line: + uid, ukey = line.split('#', 1) + accounts.append((uid.strip(), ukey.strip())) + else: + print(f"⚠️ 跳过无效行:{line}") + if not accounts: + print("❌ HZ_API 中未找到有效账号") + sys.exit(1) + return accounts + +def sign_in(uid, ukey): + # ----- 修改点:更换为正式接口地址 ----- + url = "https://cn.apihz.cn/api/xitong/function.php" + params = {"id": uid, "key": ukey, "type": 1} + try: + resp = requests.get(url, params=params, timeout=10) + resp.encoding = 'utf-8' + data = resp.json() + code = data.get('code') + if code == 200: + return True, data + else: + return False, data + except Exception as e: + return False, {"error": str(e)} + +def log_message(msg, also_print=True): + timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") + full = f"[{timestamp}] {msg}" + if also_print: + print(full) + with open(LOG_FILE, 'a', encoding='utf-8') as f: + f.write(full + '\n') + +def main(): + start_time = time.time() + log_message("========== 开始签到 ==========") + accounts = get_accounts() + log_message(f"共加载 {len(accounts)} 个账号") + + success = fail = 0 + for idx, (uid, ukey) in enumerate(accounts, 1): + display = uid[-4:] if len(uid) > 4 else uid + log_message(f"账号 {idx} (ID: ***{display}) 签到中...") + ok, data = sign_in(uid, ukey) + if ok: + success += 1 + log_message(f"✅ 账号 {idx} 签到成功!响应:{json.dumps(data, ensure_ascii=False)}") + else: + fail += 1 + msg = data.get('msg', str(data)) if isinstance(data, dict) else str(data) + log_message(f"❌ 账号 {idx} 签到失败:{msg}") + time.sleep(0.5) + + elapsed = time.time() - start_time + log_message(f"签到完成:成功 {success},失败 {fail},耗时 {elapsed:.2f} 秒") + log_message("========== 结束 ==========\n") + +if __name__ == "__main__": + main() \ No newline at end of file