修复「剩余流量」查询
This commit is contained in:
parent
fbfff5ba21
commit
53332285f3
@ -40,6 +40,9 @@ task ik_signin 0 0 1 * * ?
|
||||
|
||||
## 更新日志
|
||||
|
||||
### 2025-07-29
|
||||
- 修复「剩余流量」查询
|
||||
|
||||
### 2025-07-25
|
||||
- 智能域名发现机制。使用多种正则表达式模式从网页内容中提取域名,当域名不可用时,会从旧域名页面自动抓取新的可用域名,优先使用ikuuu相关域名,其次使用其他发现的域名
|
||||
- 增强的域名检测逻辑。能识别多种域名变更通知格式,从JavaScript跳转、登录链接等多个位置提取域名,过滤掉无效的域名格式
|
||||
|
@ -13,6 +13,7 @@ import datetime
|
||||
import urllib.parse
|
||||
import sys
|
||||
import time
|
||||
import base64
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
# 添加青龙脚本根目录到Python路径
|
||||
@ -271,8 +272,16 @@ def get_remaining_flow(cookies):
|
||||
if user_page.status_code != 200:
|
||||
return "获取流量失败", "状态码: " + str(user_page.status_code)
|
||||
|
||||
# 使用BeautifulSoup解析HTML
|
||||
soup = BeautifulSoup(user_page.text, 'html.parser')
|
||||
# 提取并解码Base64内容
|
||||
match = re.search(r'var originBody = "([^"]+)"', user_page.text)
|
||||
if not match:
|
||||
return "未找到Base64内容", ""
|
||||
|
||||
base64_content = match.group(1)
|
||||
decoded_content = base64.b64decode(base64_content).decode('utf-8')
|
||||
|
||||
# 使用BeautifulSoup解析解码后的HTML
|
||||
soup = BeautifulSoup(decoded_content, 'html.parser')
|
||||
|
||||
# 查找包含剩余流量的卡片
|
||||
flow_cards = soup.find_all('div', class_='card card-statistic-2')
|
||||
@ -292,14 +301,6 @@ def get_remaining_flow(cookies):
|
||||
|
||||
return flow_value, unit_text
|
||||
|
||||
# 如果没有找到,尝试其他方式
|
||||
flow_div = soup.find('div', string='剩余流量')
|
||||
if flow_div:
|
||||
parent_div = flow_div.find_parent('div', class_='card-body')
|
||||
if parent_div:
|
||||
flow_text = parent_div.get_text(strip=True).replace('剩余流量', '')
|
||||
return flow_text.split()[0], flow_text.split()[1] if len(flow_text.split()) > 1 else ""
|
||||
|
||||
return "未找到", "流量信息"
|
||||
|
||||
except Exception as e:
|
||||
|
Loading…
Reference in New Issue
Block a user