├── README.md ├── glados.py ├── proxy_update.py ├── ikuuu-auto-checkin.js ├── tieba.py ├── Ruishu.py ├── sendNotify.py ├── chinatelecom.py ├── yili.js └── chinatelecom.js /README.md: -------------------------------------------------------------------------------- 1 | **自用青龙脚本,详细查看[wiki](https://github.com/wq-h/qinglong/wiki/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97)** 2 | -------------------------------------------------------------------------------- /glados.py: -------------------------------------------------------------------------------- 1 | # !/usr/bin/python3 2 | # -- coding: utf-8 -- 3 | # cron: 05 08 * * * 4 | # const $ = new Env("glados 机场签到"); 5 | import datetime 6 | import requests 7 | import os 8 | import json 9 | 10 | try: 11 | from sendNotify import send 12 | except ImportError: 13 | print("加载通知服务失败") 14 | send = lambda title, message: print(f"Title: {title}\nMessage: {message}") 15 | 16 | if __name__ == '__main__': 17 | # GLaDOS cookie 18 | cookies = os.environ.get('GLADOS_COOKIES', []).split('&') 19 | if cookies[0] == '': 20 | print('未获取到GLADOS_COOKIES环境变量') 21 | cookies = [] 22 | exit(0) 23 | checkin_url = 'https://glados.rocks/api/user/checkin' 24 | status_url = 'https://glados.rocks/api/user/status' 25 | referrer = 'https://glados.rocks/console/checkin' 26 | origin = 'https://glados.rocks' 27 | useragent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' 28 | payload = { 29 | 'token': 'glados.one' 30 | } 31 | 32 | msg = "glados 机场签到结果:\n" 33 | for cookie in cookies: 34 | checkin = requests.post(checkin_url, 35 | headers={'cookie': cookie, 'referrer': referrer, 'origin': origin, 'user-agent': useragent, 'content-type': 'application/json; charset=utf-8'}, 36 | data=json.dumps(payload)) 37 | status = requests.get(status_url, headers={'cookie': cookie, 'referrer': referrer, 'origin': origin, 'user-agent': useragent}) 38 | 39 | days = str(status.json()['data']['leftDays']).split('.')[0] 40 | email = status.json()['data']['email'] 41 | 42 | balance = str(checkin.json()['list'][0]['balance']).split('.')[0] 43 | change = str(checkin.json()['list'][0]['change']).split('.')[0] 44 | 45 | if 'message' in checkin.text: 46 | msg += f"{email}|剩余:{days}天|积分:{balance}|变化:{change}\n" 47 | else: 48 | msg += f"{email} 签到失败,请更新 cookies\n" 49 | 50 | send('Glados_Sign', msg.strip()) 51 | -------------------------------------------------------------------------------- /proxy_update.py: -------------------------------------------------------------------------------- 1 | # cron: 10 */2 * * * 2 | # new Env('更新IP代理白名单'); 3 | 4 | import requests 5 | import hashlib 6 | import urllib.parse 7 | import os 8 | 9 | from sendNotify import send # 添加通知发送模块 10 | 11 | # JULIANG_KEY = '' # 填入巨量的API密钥,点击设置授权信息按钮查看,获取地址 https://www.juliangip.com/users/product/time 12 | # JULIANG_TRADE_NO = '' # 填入巨量的业务编号 13 | # XK_APIKEY = '' # 填入星空的 API Key 14 | # XK_SIGN = '' # 填入星空的 Sign 15 | # XIEQU_UID = '' # 填入携趣的 UID,获取地址 https://www.xiequ.cn/redirect.aspx?act=MyIpWhiteList.aspx 16 | # XIEQU_UKEY = '' # 填入携趣的 UKEY 17 | # YYY_UID = '' # 填入优亦云的用户套餐ID 18 | # YYY_TOKEN = '' # 填入优亦云的TOKEN 19 | # 巨量 20 | JULIANG_KEY = '' 21 | JULIANG_TRADE_NO = '' 22 | # 星空 23 | XK_APIKEY = '' 24 | XK_SIGN = '' 25 | # 携趣 26 | XIEQU_UID = '' 27 | XIEQU_UKEY = '' 28 | # 优亦云 29 | YYY_UID = '' 30 | YYY_TOKEN = '' 31 | 32 | # 青龙环境变量(若上面不填写,则读取青龙环境变量) 33 | JULIANG_KEY = JULIANG_KEY if JULIANG_KEY else os.getenv("JULIANG_KEY") 34 | JULIANG_TRADE_NO = JULIANG_TRADE_NO if JULIANG_TRADE_NO else os.getenv("JULIANG_TRADE_NO") 35 | XK_APIKEY = XK_APIKEY if XK_APIKEY else os.getenv("XK_APIKEY") 36 | XK_SIGN = XK_SIGN if XK_SIGN else os.getenv("XK_SIGN") 37 | XIEQU_UID = XIEQU_UID if XIEQU_UID else os.getenv("XIEQU_UID") 38 | XIEQU_UKEY = XIEQU_UKEY if XIEQU_UKEY else os.getenv("XIEQU_UKEY") 39 | YYY_UID = YYY_UID if YYY_UID else os.getenv("YYY_UID") 40 | YYY_TOKEN = YYY_TOKEN if YYY_TOKEN else os.getenv("YYY_TOKEN") 41 | 42 | 43 | 44 | 45 | class SignKit: 46 | 47 | @staticmethod 48 | def md5_sign(params, secret): 49 | sign_content = SignKit.get_sign_content(params) 50 | return hashlib.md5((sign_content + '&key=' + secret).encode('utf-8')).hexdigest() 51 | 52 | @staticmethod 53 | def get_sign_content(params): 54 | params.pop('sign', None) # 删除 sign 55 | sorted_params = sorted(params.items()) 56 | sign_content = '&'.join([f"{k}={str(v)}" for k, v in sorted_params if str(v) is not None and not str(v).startswith('@')]) 57 | return sign_content 58 | 59 | def get_current_ip(): 60 | response = requests.get('https://myip.ipip.net/json') 61 | data = response.json() 62 | return data['data']['ip'] 63 | 64 | def update_juliang_white_list(ip, JULIANG_KEY, JULIANG_TRADE_NO): 65 | if JULIANG_KEY and JULIANG_TRADE_NO: 66 | params = { 67 | 'new_ip': ip, 68 | 'reset': '1', 69 | 'trade_no': JULIANG_TRADE_NO 70 | } 71 | sign = SignKit.md5_sign(params, JULIANG_KEY) 72 | query_string = urllib.parse.urlencode(params) + "&sign=" + sign 73 | 74 | url = f'http://v2.api.juliangip.com/dynamic/replaceWhiteIp?{query_string}' 75 | response = requests.get(url) 76 | return response.text 77 | 78 | def update_xk_white_list(ip, XK_APIKEY, XK_SIGN): 79 | if XK_APIKEY and XK_SIGN: 80 | url = f'http://api2.xkdaili.com/tools/XApi.ashx?apikey={XK_APIKEY}&type=addwhiteip&sign={XK_SIGN}&flag=8&ip={ip}' 81 | response = requests.get(url) 82 | return response.text 83 | 84 | def update_xiequ_white_list(ip, XIEQU_UID, XIEQU_UKEY): 85 | if XIEQU_UID and XIEQU_UKEY: 86 | url = f'http://op.xiequ.cn/IpWhiteList.aspx?uid={XIEQU_UID}&ukey={XIEQU_UKEY}&act=get' 87 | response = requests.get(url) 88 | data = response.text 89 | arr = data.split(',') 90 | if ip not in arr: 91 | requests.get(f'http://op.xiequ.cn/IpWhiteList.aspx?uid={XIEQU_UID}&ukey={XIEQU_UKEY}&act=del&ip=all') 92 | response = requests.get(f'http://op.xiequ.cn/IpWhiteList.aspx?uid={XIEQU_UID}&ukey={XIEQU_UKEY}&act=add&ip={ip}') 93 | return '更新xiequ白名单成功' if response.status_code == 200 else '更新xiequ白名单出错' 94 | else: 95 | return '携趣白名单ip未变化' 96 | 97 | def update_yyy_white_list(ip, YYY_UID, YYY_TOKEN): 98 | if YYY_UID and YYY_TOKEN: 99 | url = f'http://data.yyyip.cn:88/whiteip_api?method=list&token={YYY_TOKEN}' 100 | response = requests.get(url) 101 | data = response.json() 102 | arr = [d["ip"] for d in data['data']] 103 | ipstr = ','.join(map(str, arr)) 104 | if ip not in arr: 105 | requests.get(f'http://data.yyyip.cn:88/whiteip_api?method=del&token={YYY_TOKEN}&ip={ipstr}') 106 | response = requests.get(f'http://data.yyyip.cn:88/whiteip_api?method=add&token={YYY_TOKEN}&upackid={YYY_UID}&ip={ip}') 107 | return response.json()['msg'] 108 | # return '更新优亦云白名单成功' if response.status_code == 200 else '更新优亦云白名单出错' 109 | else: 110 | return '优亦云白名单ip未变化' 111 | 112 | 113 | def main(): 114 | ip = get_current_ip() 115 | print('当前ip地址:', ip) 116 | 117 | res1 = update_juliang_white_list(ip, JULIANG_KEY, JULIANG_TRADE_NO) 118 | res2 = update_xk_white_list(ip, XK_APIKEY, XK_SIGN) 119 | res3 = update_xiequ_white_list(ip, XIEQU_UID, XIEQU_UKEY) 120 | res4 = update_yyy_white_list(ip, YYY_UID, YYY_TOKEN) 121 | 122 | print('更新巨量白名单结果:', res1) 123 | print('更新星空白名单结果:', res2) 124 | print('更新携趣白名单结果:', res3) 125 | print('更新优亦云白名单结果:', res4) 126 | 127 | # 判断是否有实际变更(不是 None 且不是“未变化”) 128 | meaningful_results = [] 129 | if res1 and '未变化' not in res1: 130 | meaningful_results.append(f"巨量:{res1}") 131 | if res2 and '未变化' not in res2: 132 | meaningful_results.append(f"星空:{res2}") 133 | if res3 and '未变化' not in res3: 134 | meaningful_results.append(f"携趣:{res3}") 135 | if res4 and '未变化' not in res4: 136 | meaningful_results.append(f"优亦云:{res4}") 137 | 138 | if meaningful_results: 139 | msg = f"""📝 当前IP地址:{ip} 140 | 🔄 有效更新结果: 141 | """ + "\n".join(meaningful_results) 142 | send("IP白名单更新通知", msg) 143 | else: 144 | print("无有效更新,无需发送通知。") 145 | 146 | 147 | if __name__ == "__main__": 148 | main() -------------------------------------------------------------------------------- /ikuuu-auto-checkin.js: -------------------------------------------------------------------------------- 1 | /* 2 | 填写注册的邮箱和密码,多账号使用;隔开 3 | export Ikuuu_EMAIL="xxx@.com;xxx@com" 4 | export Ikuuu_PASSWD="A123;A123" 5 | export Ikuuu_HOST="ikuuu.one" 6 | 由于 ikuuu 经常更换域名,添加 HOST 环境变量,默认为ikuuu.one。若域名更改,修改 HOST 的值为对应域名即可 7 | 8 | cron: 33 08 * * * 9 | const $ = new Env("ikuuu 机场签到"); 10 | */ 11 | const { sendNotify } = require("./sendNotify"); 12 | const fs = require('fs'); 13 | const path = require('path'); 14 | 15 | // 配置类 16 | class Config { 17 | static get HOST() { 18 | return process.env.Ikuuu_HOST || "ikuuu.one"; 19 | } 20 | 21 | static get PROTOCOL_PREFIX() { 22 | return "https://"; 23 | } 24 | 25 | static get LOGIN_URL() { 26 | return `${Config.PROTOCOL_PREFIX}${Config.HOST}/auth/login`; 27 | } 28 | 29 | static get CHECKIN_URL() { 30 | return `${Config.PROTOCOL_PREFIX}${Config.HOST}/user/checkin`; 31 | } 32 | } 33 | 34 | // 日志配置 35 | const logStream = fs.createWriteStream(path.join(__dirname, 'ikuuu.log'), { flags: 'a' }); 36 | 37 | function log(level, message) { 38 | const timestamp = new Date().toISOString(); 39 | const logMessage = `[${timestamp}] [${level}] ${message}\n`; 40 | logStream.write(logMessage); 41 | console.log(logMessage); 42 | } 43 | 44 | // Cookie 工具类 45 | class CookieUtil { 46 | static parseCookie(rawCookie) { 47 | let cookieSets = rawCookie.split("path=/,"); 48 | const cookies = {}; 49 | 50 | cookieSets.forEach((cookie) => { 51 | const match = cookie.match(/^([^=]+)=(.*?);/); 52 | if (match) { 53 | const fieldName = match[1].trim(); 54 | let fieldValue = match[2].trim(); 55 | fieldValue = decodeURIComponent(fieldValue); 56 | 57 | if (!cookies[fieldName]) { 58 | cookies[fieldName] = fieldValue; 59 | } 60 | } 61 | }); 62 | 63 | return cookies; 64 | } 65 | 66 | static generateCookieStr(cookieObject) { 67 | return Object.entries(cookieObject) 68 | .map(([key, value]) => `${key}=${encodeURIComponent(value)}`) 69 | .join("; "); 70 | } 71 | } 72 | 73 | // Ikuuu 客户端类 74 | class IkuuuClient { 75 | constructor(email, password) { 76 | this.email = email; 77 | this.password = password; 78 | } 79 | 80 | async login() { 81 | log('INFO', `Logging in with email: ${this.email}...`); 82 | 83 | let formData = new FormData(); 84 | formData.append("host", Config.HOST); 85 | formData.append("email", this.email); 86 | formData.append("passwd", this.password); 87 | formData.append("code", ""); 88 | formData.append("remember_me", "off"); 89 | 90 | try { 91 | let response = await fetch(Config.LOGIN_URL, { 92 | method: "POST", 93 | body: formData, 94 | }); 95 | 96 | let rawCookie = response.headers.get("set-cookie"); 97 | let responseJson = await response.json(); 98 | 99 | if (responseJson) { 100 | log('INFO', responseJson.msg); 101 | } 102 | 103 | return CookieUtil.parseCookie(rawCookie); 104 | } catch (error) { 105 | log('ERROR', `Login failed for ${this.email}: ${error.message}`); 106 | throw error; 107 | } 108 | } 109 | 110 | async checkIn(cookie) { 111 | try { 112 | let response = await fetch(Config.CHECKIN_URL, { 113 | method: "POST", 114 | headers: { 115 | Cookie: CookieUtil.generateCookieStr(cookie), 116 | }, 117 | }); 118 | 119 | let responseJson = await response.json(); 120 | if (responseJson) { 121 | log('INFO', responseJson.msg); 122 | } 123 | } catch (error) { 124 | log('ERROR', `Check-in failed for ${this.email}: ${error.message}`); 125 | throw error; 126 | } 127 | } 128 | } 129 | 130 | // 延迟函数,单位为毫秒 131 | function delay(ms) { 132 | return new Promise(resolve => setTimeout(resolve, ms)); 133 | } 134 | 135 | async function main() { 136 | let emails = process.env.Ikuuu_EMAIL; 137 | let passwords = process.env.Ikuuu_PASSWD; 138 | 139 | if (!emails || !passwords) { 140 | log('ERROR', "ENV ERROR: Please set both Ikuuu_EMAIL and Ikuuu_PASSWD."); 141 | process.exit(1); 142 | } 143 | 144 | let emailList = emails.split(";"); 145 | let passwdList = passwords.split(";"); 146 | 147 | if (emailList.length !== passwdList.length) { 148 | log('ERROR', "Error: The number of emails does not match the number of passwords."); 149 | process.exit(1); 150 | } 151 | 152 | let notifications = []; 153 | 154 | for (let i = 0; i < emailList.length; i++) { 155 | let email = emailList[i]; 156 | let passwd = passwdList[i]; 157 | let client = new IkuuuClient(email, passwd); 158 | 159 | try { 160 | let cookie = await client.login(); 161 | await client.checkIn(cookie); 162 | notifications.push(`账号 ${email} 登录成功,签到完成`); 163 | } catch (error) { 164 | notifications.push(`账号 ${email} 操作失败: ${error.message}`); 165 | } 166 | 167 | await delay(2000); // 延迟 2 秒 168 | } 169 | 170 | // 过滤掉 undefined 值 171 | const notificationMessage = notifications 172 | .filter(msg => msg !== undefined) 173 | .join("\n"); 174 | 175 | // 调试:打印通知数组 176 | console.log("通知数组内容:", notifications); 177 | 178 | sendNotify(`多个账号操作完成:\n${notificationMessage}`); 179 | } 180 | 181 | main().catch(error => { 182 | log('ERROR', `Main function failed: ${error.message}`); 183 | process.exit(1); 184 | }); 185 | -------------------------------------------------------------------------------- /tieba.py: -------------------------------------------------------------------------------- 1 | # !/usr/bin/python3 2 | # -- coding: utf-8 -- 3 | # cron: 00 08 * * * 4 | # const $ = new Env("贴吧签到"); 5 | 6 | import os 7 | import time 8 | from requests import session 9 | from hashlib import md5 10 | from concurrent.futures import ThreadPoolExecutor, as_completed 11 | 12 | try: 13 | from sendNotify import send 14 | except ImportError: 15 | print("加载通知服务失败") 16 | 17 | class Tieba(): 18 | # 将配置项提取为类变量 19 | MAX_RETRY = 10 # 最大重试次数 20 | REQUEST_TIMEOUT = 30 # 请求超时时间 21 | SLEEP_TIME = 10 # 退出前等待时间 22 | 23 | Tieba_BDUSS = os.getenv("Tieba_BDUSS") 24 | 25 | def __init__(self, STOKEN): 26 | self.BDUSS = Tieba.Tieba_BDUSS 27 | self.STOKEN = STOKEN 28 | self.success_list = [] 29 | self.result = {} 30 | self.sign_list = [] 31 | self.fail_list = [] 32 | self.session = session() 33 | self.session.headers.update( 34 | {'Accept': 'text/html, */*; q=0.01', 35 | 'Accept-Encoding': 'gzip, deflate', 36 | 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', 37 | 'Connection': 'keep-alive', 38 | 'Host': 'tieba.baidu.com', 39 | 'Referer': 'http://tieba.baidu.com/i/i/forum', 40 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' 41 | 'Chrome/71.0.3578.98 Safari/537.36', 42 | 'X-Requested-With': 'XMLHttpRequest'} 43 | ) 44 | 45 | def set_cookie(self): 46 | self.session.cookies.update({'BDUSS': self.BDUSS, 'STOKEN': self.STOKEN}) 47 | 48 | def fetch_tbs(self): 49 | try: 50 | r = self.session.get('http://tieba.baidu.com/dc/common/tbs').json() 51 | if r['is_login'] == 1: 52 | self.tbs = r['tbs'] 53 | else: 54 | raise Exception('获取tbs错误!以下为返回数据:' + str(r)) 55 | except Exception as e: 56 | raise Exception(f'获取tbs时发生异常:{str(e)}') 57 | 58 | def fetch_likes(self): 59 | try: 60 | self.rest = set() 61 | self.already = set() 62 | r = self.session.get('https://tieba.baidu.com/mo/q/newmoindex?').json() 63 | if r['no'] == 0: 64 | for forum in r['data']['like_forum']: 65 | if forum['is_sign'] == 1: 66 | self.already.add(forum['forum_name']) 67 | else: 68 | self.rest.add(forum['forum_name']) 69 | else: 70 | raise Exception('获取关注贴吧错误!以下为返回数据:' + str(r)) 71 | except Exception as e: 72 | raise Exception(f'获取关注贴吧时发生异常:{str(e)}') 73 | 74 | def sign(self, forum_name): 75 | try: 76 | data = { 77 | 'kw': forum_name, 78 | 'tbs': self.tbs, 79 | 'sign': md5(f'kw={forum_name}tbs={self.tbs}tiebaclient!!!'.encode('utf8')).hexdigest() 80 | } 81 | r = self.session.post('http://c.tieba.baidu.com/c/c/forum/sign', data, timeout=self.REQUEST_TIMEOUT).json() 82 | if r['error_code'] == '160002': 83 | print(f'"{forum_name}"已签到') 84 | self.sign_list.append(forum_name) 85 | return True 86 | elif r['error_code'] == '0': 87 | print(f'"{forum_name}">>>>>>>签到成功,您是第{r["user_info"]["user_sign_rank"]}个签到的用户!') 88 | self.result[forum_name] = r 89 | self.success_list.append(forum_name) 90 | return True 91 | else: 92 | print(f'"{forum_name}"签到失败!以下为返回数据:{str(r)}') 93 | self.fail_list.append(forum_name) 94 | return False 95 | except Exception as e: 96 | print(f'"{forum_name}"签到时发生异常:{str(e)}') 97 | self.fail_list.append(forum_name) 98 | return False 99 | 100 | def loop(self, n): 101 | print(f'* 开始第{n}轮签到 *') 102 | rest = set() 103 | self.fetch_tbs() 104 | # 使用线程池并发签到 105 | with ThreadPoolExecutor(max_workers=5) as executor: 106 | futures = {executor.submit(self.sign, forum_name): forum_name for forum_name in self.rest} 107 | for future in as_completed(futures): 108 | forum_name = futures[future] 109 | try: 110 | if not future.result(): 111 | rest.add(forum_name) 112 | except Exception as e: 113 | print(f'"{forum_name}"签到异常:{str(e)}') 114 | rest.add(forum_name) 115 | self.rest = rest 116 | if n >= self.MAX_RETRY: # 使用类变量 117 | self.rest = set() 118 | 119 | def main(self, max): 120 | self.set_cookie() 121 | self.fetch_likes() 122 | n = 0 123 | if self.already: 124 | print('---------- 已经签到的贴吧 ---------') 125 | for forum_name in self.already: 126 | print(f'"{forum_name}"已签到') 127 | self.sign_list.append(forum_name) 128 | while n < max and self.rest: 129 | n += 1 130 | self.loop(n) 131 | 132 | if self.rest: 133 | print('--------- 签到失败列表 ----------') 134 | for forum_name in self.rest: 135 | print(f'"{forum_name}"签到失败!') 136 | 137 | # 在签到结束后调用 send 函数发送通知 138 | self.send_notification_message() 139 | 140 | def send_notification_message(self): 141 | try: 142 | msg = "贴吧签到结果:\n" 143 | 144 | if self.success_list: 145 | msg += "- **签到成功贴吧**:\n" 146 | for forum in self.success_list: 147 | sign_rank = self.result[forum]['user_info']['user_sign_rank'] 148 | msg += f" {forum} (签到成功,第{sign_rank}个签到)\n" 149 | 150 | if self.sign_list: 151 | msg += "- **已经签到的贴吧**:\n" 152 | msg += " " + ", ".join(self.sign_list) # 去掉末尾的换行符 153 | 154 | # 直接拼接统计信息,去掉前面的空行 155 | msg += f"\n共关注了{len(self.already) + len(self.success_list)}个贴吧," 156 | msg += f"本次成功签到了{len(self.success_list)}个," 157 | msg += f"失败了{len(self.fail_list)}个," 158 | msg += f"有{len(self.sign_list)}个贴吧已经签到。" 159 | 160 | # 发送通知 161 | send('Tieba_Sign', msg) 162 | 163 | # 使用类变量 164 | time.sleep(self.SLEEP_TIME) 165 | except Exception as e: 166 | print(f'发送通知时发生异常:{str(e)}') 167 | 168 | if __name__ == "__main__": 169 | BDUSS_values = os.getenv("Tieba_BDUSS") 170 | STOKEN = '' 171 | task = Tieba(STOKEN) 172 | print("\n========================\n") 173 | task.main(3) 174 | print("----------贴吧签到执行完毕----------") 175 | -------------------------------------------------------------------------------- /Ruishu.py: -------------------------------------------------------------------------------- 1 | import os 2 | import ssl 3 | import time 4 | import json 5 | import execjs 6 | import base64 7 | import random 8 | import certifi 9 | import aiohttp 10 | import asyncio 11 | import requests 12 | from http import cookiejar 13 | from Crypto.Cipher import DES3 14 | from Crypto.Util.Padding import pad, unpad 15 | from aiohttp import ClientSession, TCPConnector 16 | import httpx 17 | import logging 18 | 19 | diffValue = 2 20 | filename='Cache.js' 21 | if os.path.exists(filename): 22 | with open(filename, 'r', encoding='utf-8') as file: 23 | fileContent = file.read() 24 | else: 25 | fileContent='' 26 | 27 | class BlockAll(cookiejar.CookiePolicy): 28 | return_ok = set_ok = domain_return_ok = path_return_ok = lambda self, *args, **kwargs: False 29 | netscape = True 30 | rfc2965 = hide_cookie2 = False 31 | 32 | def printn(m): 33 | print(f'\n{m}') 34 | 35 | context = ssl.create_default_context() 36 | context.set_ciphers('DEFAULT@SECLEVEL=1') # 低安全级别0/1 37 | context.check_hostname = False # 禁用主机 38 | context.verify_mode = ssl.CERT_NONE # 禁用证书 39 | 40 | class DESAdapter(requests.adapters.HTTPAdapter): 41 | def init_poolmanager(self, *args, **kwargs): 42 | kwargs['ssl_context'] = context 43 | return super().init_poolmanager(*args, **kwargs) 44 | 45 | requests.DEFAULT_RETRIES = 0 46 | requests.packages.urllib3.disable_warnings() 47 | ss = requests.session() 48 | ss.headers = {"User-Agent": "Mozilla/5.0 (Linux; Android 13; 22081212C Build/TKQ1.220829.002) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.97 Mobile Safari/537.36", "Referer": "https://wapact.189.cn:9001/JinDouMall/JinDouMall_independentDetails.html"} 49 | ss.mount('https://', DESAdapter()) 50 | ss.cookies.set_policy(BlockAll()) 51 | runTime = 0 52 | sleepTime = 1 53 | key = b'1234567`90koiuyhgtfrdews' 54 | iv = 8 * b'\0' 55 | 56 | def encrypt(text): 57 | cipher = DES3.new(key, DES3.MODE_CBC, iv) 58 | ciphertext = cipher.encrypt(pad(text.encode(), DES3.block_size)) 59 | return ciphertext.hex() 60 | 61 | def decrypt(text): 62 | ciphertext = bytes.fromhex(text) 63 | cipher = DES3.new(key, DES3.MODE_CBC, iv) 64 | plaintext = unpad(cipher.decrypt(ciphertext), DES3.block_size) 65 | return plaintext.decode() 66 | 67 | ssl_context = ssl.create_default_context() 68 | ssl_context.set_ciphers('DEFAULT@SECLEVEL=1') 69 | ssl_context.check_hostname = False 70 | ssl_context.verify_mode = ssl.CERT_NONE 71 | 72 | custom_client = httpx.Client( 73 | verify=False, 74 | http2=False, 75 | transport=httpx.HTTPTransport( 76 | retries=0, 77 | verify=ssl_context 78 | ) 79 | ) 80 | 81 | # 添加日志记录 82 | logging.basicConfig( 83 | level=logging.INFO, 84 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' 85 | ) 86 | logger = logging.getLogger(__name__) 87 | 88 | def initCookie(getUrl='https://wapact.189.cn:9001/gateway/standQuery/detailNew/exchange'): 89 | try: 90 | global js_code_ym, fileContent 91 | response = custom_client.post(getUrl) 92 | response.raise_for_status() 93 | 94 | # 解析响应内容 95 | content = response.text.split(' content="')[2].split('" r=')[0] 96 | code1 = response.text.split('$_ts=window')[1].split('