1.购买服务器阿里云:服务器购买地址https://t.aliyun.com/U/Bg6shY若失效,可用地址
阿里云:
服务器购买地址
https://t.aliyun.com/U/Bg6shY若失效,可用地址
https://www.aliyun.com/daily-act/ecs/activity_selection?source=5176.29345612&userCode=49hts92d腾讯云:
https://curl.qcloud.com/wJpWmSfU若失效,可用地址
https://cloud.tencent.com/act/cps/redirect?redirect=2446&cps_key=ad201ee2ef3b771157f72ee5464b1fea&from=console华为云
https://activity.huaweicloud.com/cps.html?fromacct=64b5cf7cc11b4840bb4ed2ea0b2f4468&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=2019052.部署教程
3.代码如下
# 请不要异地签到,最起码在本地先登陆下# cron: 10 8 * * *# new Env('杜比');import requestsimport re,timeimport os,sysfrom notify import senddef pr(message):msg.append(message + "\n")print(message)msg = []s = requests.session()def index(cookie):url = 'https://www.hddolby.com/index.php'header = {"authority": "www.hddolby.com","method": "GET","path": "/index.php","User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36","content-type": "text/html; charset=utf-8; Cache-control:private","host":"www.hddolby.com","referer":"https://www.hddolby.com/index.php","cookie":cookie}try:response = s.get(url=url,headers=header)info = response.texttime.sleep(3)if "首页" in info:pr("登陆成功")attendance(cookie)else:pr("登录失败")except Exception as e:pr(e)def attendance(cookie):url = 'https://www.hddolby.com/attendance.php'header = {"authority": "www.hddolby.com","method": "GET","path": "/attendance.php","User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36","content-type": "text/html; charset=utf-8; Cache-control:private","host":"www.hddolby.com","referer":"https://www.hddolby.com/index.php","cookie":cookie}try:response = s.get(url=url,headers=header)info = response.texttime.sleep(3)if "签到已得" in info:pr("签到成功,请勿重复刷新。")torrents(cookie)else :pr("签到中...")attendance(cookie)except Exception as e:pr(e)def torrents(cookie):url = 'https://www.hddolby.com/torrents.php'header = {"authority": "www.hddolby.com","method": "GET","path": "/torrents.php","User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36","content-type": "text/html; charset=utf-8; Cache-control:private","host":"www.hddolby.com","referer":"https://www.hddolby.com/attendance.php","cookie":cookie}try:response = s.get(url=url,headers=header)time.sleep(5)pattern = re.compile(r"class='UltimateUser_Name'><b>(.+?)</b>")pattern2 = re.compile(r']: (.*) \(')pattern3 = re.compile(r'签到已得(.*?)\) ')matches = pattern.findall(response.text)matches1 = pattern2.findall(response.text)matches2 = pattern3.findall(response.text)if not matches or not matches1 or not matches2:pr("解析用户信息失败,可能页面结构变化或 cookie 无效")returnpr( "用户名:" + matches[0] + " 鲸币:" + matches1[0] + " 签到已得:" + matches2[0])except Exception as e:pr(e)def sicxs():config_path = 'config.py'if os.path.exists(config_path):import configelse:with open(config_path, 'w') as f:pr("首次运行,已创建配置文件 config.py,请按照说明填写相关变量后再次运行脚本。")f.write('#可以在此文件中添加配置变量,例如:\nsfsy = ""\n')try:env_cookie = os.environ.get("wy_hddolby")si_cookie = getattr(config, 'wy_hddolby', '')if env_cookie and si_cookie:cookies = env_cookie + "\n" + si_cookieelif env_cookie:cookies = env_cookieelif si_cookie:cookies = si_cookieelse:pr("请设置变量 export wy_hddolby='' 或在 config.py 中设置 wy_hddolby")sys.exit()except Exception as e:print("请设置变量 export wy_hddolby='' 或在 config.py 中设置 wy_hddolby")sys.exit()list_cookie = re.split(r'\n|&|@', cookies)total_cookies = len(list_cookie)for i, list_cookie_i in enumerate(list_cookie):pr(f'\n----------- 账号【{i + 1}/{total_cookies}】执行 -----------')pr(f"账号【{i + 1}】开始执行:")try:index(list_cookie_i)except Exception as e:pr(f"执行账号【{i + 1}】时发生错误: {e}")finally:send("杜比PT站", ''.join(msg))msg.clear()print(f'\n----------- 执 行 结 束 -----------')if __name__ == '__main__':sicxs()
该脚本为杜比 PT 站自动签到脚本。
主要作用
与信息汇总:用提供的
cookie访问www.hddolby.com,先在首页校验登录,再进入attendance.php完成签到,随后到torrents.php抓取并输出用户名 / 鲸币 / 当日签到收益等信息。多账号与通知:支持从环境变量或
config.py读取多个账号(用换行、&、@分隔),逐个执行并通过notify.send("杜比PT站", …)推送结果;示例cron: 10 8 * * *每天 08:10 运行。会话复用:使用全局
requests.session()维持同一会话,减少重复握手/增强稳定性。
主要方法
pr(message): 统一打印并写入全局msg缓存,便于每个账号执行完统一通知。index(cookie): 访问index.php判断是否登录成功;成功则转入attendance(cookie),否则提示失败。attendance(cookie): 访问attendance.php执行签到;若页面包含"签到已得"视为成功并进入torrents(cookie);否则打印"签到中..."并再次调用自身(轮询直至出现成功文案)。torrents(cookie): 访问torrents.php,用正则提取:class='UltimateUser_Name'><b>…</b>→ 用户名']: (.*) \('→ 鲸币'签到已得(.*?)\) '→ 当日签到收益
成功后按格式输出;若匹配不到则提示"解析用户信息失败(可能页面改版或 cookie 失效)"。sicxs()(入口/调度):初始化或创建
config.py;合并读取
wy_hddolby(环境变量与config.py中同名变量);按分隔符拆分多账号循环调用
index();每个账号执行完发送一次通知并清空
msg。
备注/小提示
异地登录风险:脚本注释已提示"请不要异地签到,至少先本地登录一次",以免触发风控导致 cookie 失效。
轮询实现:
attendance()采用递归自调用方式轮询,若站点长期不返回"签到已得"文案,可能造成过长等待/递归深度问题;可考虑改为while轮询并增加最大重试与睡眠间隔。多账号分隔:
wy_hddolby支持用换行 /&/@分隔;示例:export wy_hddolby='cookieA&cookieB@cookieC'。
注意:
本文部分变量已做脱敏处理,仅用于测试和学习研究,禁止用于商业用途,不能保证其合法性,准确性,完整性和有效性,请根据情况自行判断。技术层面需要提供帮助,可以通过打赏的方式进行探讨。
没有评论:
发表评论