mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-Nonebot.git
synced 2026-04-01 22:04:51 +00:00
删除测试wenku8连通
This commit is contained in:
parent
e7db5f75e2
commit
b2184fe7a9
1 changed files with 1 additions and 56 deletions
|
|
@ -8,7 +8,7 @@ from src.clover_openai import ai_chat
|
|||
from src.clover_sqlite.models.chat import GroupChatRole
|
||||
from src.clover_sqlite.models.user import UserList
|
||||
|
||||
menu = ['/重启','/wenku8','/今日运势','/今日塔罗','/图','/日报','/点歌','/摸摸头','/群老婆','/今日老婆', "/开启ai","/关闭ai","/角色列表","/添加人设", "/更新人设", "/删除人设", "/切换人设", "/管理员注册",
|
||||
menu = ['/重启','/今日运势','/今日塔罗','/图','/日报','/点歌','/摸摸头','/群老婆','/今日老婆', "/开启ai","/关闭ai","/角色列表","/添加人设", "/更新人设", "/删除人设", "/切换人设", "/管理员注册",
|
||||
'/待办', '/test','/天气','我喜欢你', "❤", "/待办查询", "/新建待办", "/删除待办" ,"/cf","/B站搜索", "/BV搜索", "/喜报", "/悲报", "/luxun","/鲁迅说",
|
||||
"/奶龙", "/repo", "/info", "/menu", "/轻小说"]
|
||||
|
||||
|
|
@ -84,58 +84,3 @@ test = on_command("test", rule=to_me(), priority=10, block=True)
|
|||
@test.handle()
|
||||
async def bot_on_ready():
|
||||
await test.finish("\nBoost & Magnum, ready fight!!!")
|
||||
|
||||
|
||||
import requests
|
||||
from requests.adapters import HTTPAdapter
|
||||
from intake.readers import Retry
|
||||
from src.configs.api_config import wenku8_username, wenku8_password
|
||||
# 登录页面的URL
|
||||
login_url = 'https://www.wenku8.net/login.php?jumpurl=http%3A%2F%2Fwww.wenku8.net%2Findex.php'
|
||||
index_url = 'https://www.wenku8.net/index.php'
|
||||
|
||||
headers = {
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
|
||||
'Connection': 'keep-alive',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.41',
|
||||
'Upgrade-Insecure-Requests': '1',
|
||||
}
|
||||
|
||||
# 登录表单数据
|
||||
login_data = {
|
||||
'username': wenku8_username,
|
||||
'password': wenku8_password,
|
||||
'usecookie': '0',
|
||||
'action': 'login'
|
||||
}
|
||||
|
||||
wenku8 = on_command("wenku8", rule=to_me(), priority=10, block=True)
|
||||
@wenku8.handle()
|
||||
async def wenku8():
|
||||
# 创建会话
|
||||
session = requests.Session()
|
||||
|
||||
# 重试策略
|
||||
retry_strategy = Retry(
|
||||
total=3,
|
||||
backoff_factor=1,
|
||||
status_forcelist=[500, 502, 503, 504],
|
||||
allowed_methods=["POST"]
|
||||
)
|
||||
adapter = HTTPAdapter(max_retries=retry_strategy)
|
||||
session.mount('https://', adapter)
|
||||
session.mount('http://', adapter)
|
||||
|
||||
try:
|
||||
# 发送登录请求
|
||||
login_response = session.post(login_url, data=login_data, headers=headers)
|
||||
# 检查登录是否成功(根据实际需求调整)
|
||||
if login_response.status_code == 200:
|
||||
# 登录成功后,Session对象已经自动保存了Cookie
|
||||
# 可以直接使用该Session对象访问受保护的页面
|
||||
print("登录成功!")
|
||||
else:
|
||||
print(f"登录失败,状态码: {login_response.status_code}")
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"请求出错: {e}")
|
||||
Loading…
Reference in a new issue