卡农社区每日自动签到 py 脚本
复制代码创建 py 后缀的文件
变量名 KQ_COOKIE
数据格式 3df5d0fc98d8c119af2e389a3f45b5b0=7b02f71362a5daef01598510d2dd9f5d,PHPSESSID=8dd80c152e8806cefe55e174935c0926
两个 CK 谢谢
# 风险提示声明
print("=" * 80)
print("⚠️ 脚本使用风险提示")
print("=" * 80)
print("本脚本旨在便利学术研究,但其使用可能涉及法律风险。请仔细阅读以下内容:")
print("1. 使用目的:仅限于个人学习、研究或欣赏,以及教学、科学研究等非商业用途。严禁用于任何商业目的。")
print("2. 免责声明:本脚本免费,仅供学习交流使用。使用本脚本产生的所有问题与本项目及开发者团队无关。")
print("3. 账户风险:作者哗哗。使用期间如遇到账户被限制、封禁等异常情况,与作者无关。使用本脚本即表示您同意上述条款。")
print("=" * 80)
print()
import os
import requests
import time
import datetime
# 核心配置
COOKIE_VAR_NAME = "KQ_COOKIE"
SIGN_URL = "https://my.kanongquan.com/mag/addon/v1/sign/signReward"
USER_AGENT = "Mozilla/5.0 (Linux; Android 10; V1914A Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/89.0.4389.72 MQQBrowser/6.2 TBS/046295 Mobile Safari/537.36"
MAX_RETRIES = 3
RETRY_INTERVAL = 6
def get_headers(cookie):
return {
"Cookie": cookie,
"User-Agent": USER_AGENT,
"Referer": "https://my.kanongquan.com/",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"X-Requested-With": "XMLHttpRequest"
}
def load_accounts():
cookie_str = os.getenv(COOKIE_VAR_NAME)
if not cookie_str:
print(f"[{datetime.datetime.now()}] ⚠️ 未检测到有效账号!请创建环境变量 '{COOKIE_VAR_NAME}'")
print(f"[{datetime.datetime.now()}] ⚠️ 示例格式:3df5d0fc98d8c119af2e389a3f45b5b0=ef632c41067e6a178f87dd3c57b14e82; PHPSESSID=d784e9478bb7a2d79558e6875ac07351")
return []
cookies = [c.strip() for c in cookie_str.split(',') if c.strip()]
accounts = []
for idx, cookie in enumerate(cookies):
parts = cookie.split('&', 1)
if len(parts) == 2:
note = parts[0].strip()
real_cookie = parts[1].strip()
else:
note = f"账号{idx+1}"
real_cookie = cookie.strip()
accounts.append({"index": idx+1, "note": note, "cookie": real_cookie})
return accounts
def check_login_status(cookie):
try:
response = requests.get(SIGN_URL, headers=get_headers(cookie), timeout=10)
result = response.json()
if (result.get("code") in ["10001", 0]) and (result.get("msg") in ["请先登陆", "请先登录"]):
return False
return True
except Exception as e:
print(f"[{datetime.datetime.now()}] ❌ 登录状态校验异常:{str(e)}")
return False
def auto_sign(account):
idx = account["index"]
note = account["note"]
cookie = account["cookie"]
print(f"\n[{datetime.datetime.now()}] === 开始处理账号{idx}({note})===")
if not check_login_status(cookie):
print(f"[{datetime.datetime.now()}] ❌ 账号{idx}({note}):Cookie失效,跳过")
return False
for retry in range(MAX_RETRIES):
try:
response = requests.post(SIGN_URL, headers=get_headers(cookie), data={}, timeout=10)
result = response.json()
if result.get("success"):
reward = result.get("data", {}).get("reward", "无")
print(f"[{datetime.datetime.now()}] ✅ 账号{idx}({note}):签到成功!奖励:{reward}")
return True
elif result.get("msg") == "今日已签过到,明天再来吧!":
print(f"[{datetime.datetime.now()}] ℹ️ 账号{idx}({note}):今日已签到,无需重复操作")
return True
elif "手速太快" in result.get("msg", ""):
print(f"[{datetime.datetime.now()}] ⚠️ 账号{idx}({note}):手速太快提示,已自动视为签到成功")
return True
else:
error_msg = result.get("msg", "未知错误")
print(f"[{datetime.datetime.now()}] ❌ 账号{idx}({note}):第{retry+1}次签到失败:{error_msg}")
except Exception as e:
print(f"[{datetime.datetime.now()}] ❌ 账号{idx}({note}):第{retry+1}次请求异常:{str(e)}")
if retry < MAX_RETRIES - 1:
print(f"[{datetime.datetime.now()}] ⏳ 账号{idx}({note}):等待{RETRY_INTERVAL}秒后重试...")
time.sleep(RETRY_INTERVAL)
print(f"[{datetime.datetime.now()}] ❌ 账号{idx}({note}):达到最大重试次数,跳过")
return False
def main():
print(f"[{datetime.datetime.now()}] === 启动多账号签到任务 ===")
accounts = load_accounts()
if not accounts:
return
print(f"[{datetime.datetime.now()}] 📊 共检测到 {len(accounts)} 个账号,开始依次执行...")
success_count = 0
for account in accounts:
if auto_sign(account):
success_count += 1
time.sleep(1)
print(f"\n[{datetime.datetime.now()}] === 所有账号处理完毕 ===")
print(f"[{datetime.datetime.now()}] 📈 汇总:总账号数 {len(accounts)} | 成功 {success_count} | 失败 {len(accounts)-success_count}")
if __name__ == "__main__":
main()
© 版权声明
本站内容均转载于互联网,并不代表本站立场!如若本站内容侵犯了原著者的合法权益,可联系我们进行处理!邮箱64067887@qq.com
拒绝任何人以任何形式在本站发表与中华人民共和国法律相抵触的言论!
THE END












