mirror of
https://github.com/smallfawn/QLScriptPublic.git
synced 2026-01-14 14:32:44 +08:00
Compare commits
3 Commits
9c2e5d54b9
...
697ae9fb91
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
697ae9fb91 | ||
|
|
a1c1bce2f0 | ||
|
|
413c0c9b2d |
145
51dalili.py
Normal file
145
51dalili.py
Normal file
@ -0,0 +1,145 @@
|
||||
#51代理每日签到
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import time
|
||||
import os
|
||||
|
||||
def login_to_51daili():
|
||||
# 从环境变量读取账号和密码
|
||||
username = os.getenv('dali51user')
|
||||
password = os.getenv('daili51pass')
|
||||
|
||||
if not username or not password:
|
||||
print("错误: 请设置环境变量 dali51user 和 daili51pass")
|
||||
return None
|
||||
|
||||
# 第一次请求获取登录令牌和PHPSESSID
|
||||
print("正在获取登录令牌和PHPSESSID...")
|
||||
session = requests.Session()
|
||||
|
||||
try:
|
||||
# 初始headers,仅包含User-Agent
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
|
||||
}
|
||||
|
||||
# 发送GET请求获取登录页面
|
||||
response = session.get('https://www.51daili.com', headers=headers, timeout=10)
|
||||
response.raise_for_status()
|
||||
|
||||
# 从响应头中获取PHPSESSID
|
||||
phpsessid = None
|
||||
if 'set-cookie' in response.headers:
|
||||
cookies = response.headers['set-cookie'].split(';')
|
||||
for cookie in cookies:
|
||||
if 'PHPSESSID' in cookie:
|
||||
phpsessid = cookie.split('=')[1]
|
||||
break
|
||||
|
||||
# 解析HTML获取令牌
|
||||
soup = BeautifulSoup(response.text, 'html.parser')
|
||||
token_input = soup.find('input', {'name': '__login_token__'})
|
||||
|
||||
if token_input:
|
||||
login_token = token_input.get('value')
|
||||
print(f"成功获取登录令牌: {login_token}")
|
||||
else:
|
||||
print("未找到登录令牌,使用默认令牌")
|
||||
login_token = "14f2877f31842495ff24e3d73036158a"
|
||||
|
||||
if phpsessid:
|
||||
print(f"成功获取PHPSESSID: {phpsessid}")
|
||||
else:
|
||||
print("未能从响应头中获取PHPSESSID,使用默认值")
|
||||
phpsessid = "qkheban0ocfthart1bk7s861kn"
|
||||
|
||||
# 准备登录数据和更新headers
|
||||
login_data = {
|
||||
'__login_token__': login_token,
|
||||
'account': username,
|
||||
'password': password,
|
||||
'ticket': '1',
|
||||
'keeplogin': '1',
|
||||
'is_read': '1'
|
||||
}
|
||||
|
||||
# 更新headers,添加Cookie
|
||||
headers['Cookie'] = f"PHPSESSID={phpsessid};tncode_check=ok"
|
||||
|
||||
print("正在尝试登录...")
|
||||
time.sleep(1) # 添加短暂延迟
|
||||
|
||||
# 发送POST请求进行登录
|
||||
login_url = 'https://www.51daili.com/index/user/login.html'
|
||||
login_response = session.post(login_url, data=login_data, headers=headers, timeout=10)
|
||||
login_response.raise_for_status()
|
||||
|
||||
# 检查登录是否成功
|
||||
if login_response.status_code == 200:
|
||||
print("登录请求已发送,状态码: 200")
|
||||
|
||||
# 尝试从响应头中查找token
|
||||
print("响应头:", login_response.headers)
|
||||
|
||||
token = None
|
||||
# 检查Set-Cookie头
|
||||
if 'set-cookie' in login_response.headers:
|
||||
cookies = login_response.headers['set-cookie'].split(';')
|
||||
for cookie in cookies:
|
||||
if 'token' in cookie.lower():
|
||||
print(f"找到token cookie: {cookie}")
|
||||
# 提取token值
|
||||
token_parts = cookie.split('=')
|
||||
if len(token_parts) >= 2:
|
||||
token = token_parts[1].strip()
|
||||
break
|
||||
|
||||
# 如果没有在Set-Cookie中找到,检查其他头字段
|
||||
if not token:
|
||||
for key, value in login_response.headers.items():
|
||||
if 'token' in key.lower():
|
||||
print(f"找到token头: {key}: {value}")
|
||||
token = value
|
||||
break
|
||||
|
||||
if token:
|
||||
print(f"成功获取token: {token}")
|
||||
|
||||
# 使用token请求签到页面
|
||||
signin_headers = headers.copy()
|
||||
# 添加token到Cookie
|
||||
signin_headers['Cookie'] = f"{signin_headers.get('Cookie', '')}; token={token}"
|
||||
signin_headers['Referer'] = 'https://www.51daili.com/'
|
||||
|
||||
print("正在请求签到页面...")
|
||||
signin_response = session.get(
|
||||
'https://www.51daili.com/index/user/signin.html',
|
||||
headers=signin_headers,
|
||||
timeout=10
|
||||
)
|
||||
signin_response.raise_for_status()
|
||||
|
||||
print("签到页面响应内容:")
|
||||
print(signin_response.text)
|
||||
else:
|
||||
print("未能从登录响应中提取token")
|
||||
else:
|
||||
print(f"登录请求返回异常状态码: {login_response.status_code}")
|
||||
|
||||
return session
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"请求过程中发生错误: {e}")
|
||||
return None
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("51代理登录示例")
|
||||
print("=" * 30)
|
||||
|
||||
session = login_to_51daili()
|
||||
|
||||
if session:
|
||||
print("登录流程完成")
|
||||
# 这里可以继续使用session进行后续操作
|
||||
else:
|
||||
print("登录失败")
|
||||
@ -12,51 +12,8 @@ const env_name = 'yybpc' //环境变量名字
|
||||
const env = process.env[env_name] || ''
|
||||
const Notify = 1
|
||||
const debug = 0
|
||||
let scriptVersionNow = "1.0.0";
|
||||
let scriptVersionNow = "1.0.1";
|
||||
let msg = "";
|
||||
// ==================================异步顺序==============================================================================
|
||||
!(async () => {
|
||||
//await getNotice(); //远程通知
|
||||
//await getVersion("yang7758258/ohhh154@main/yybpc.js");
|
||||
await main();//主函数
|
||||
await SendMsg(msg); //发送通知
|
||||
|
||||
})()
|
||||
.catch((e) => $.logErr(e))
|
||||
.finally(() => $.done());
|
||||
//==================================脚本入口函数main()==============================================================
|
||||
|
||||
async function main() {
|
||||
if (env == '') {
|
||||
//没有设置变量,直接退出
|
||||
console.log(`没有填写变量,请查看脚本说明: ${env_name}`)
|
||||
return
|
||||
}
|
||||
let user_ck = env.split('\n')
|
||||
DoubleLog(`\n========= 共找到 ${user_ck.length} 个账号 =========`);
|
||||
let index = 1 //用来给账号标记序号, 从1开始
|
||||
for (let ck of user_ck) {
|
||||
if (!ck) continue //跳过空行
|
||||
let ck_info = ck.split('&')
|
||||
let Authorization = ck_info[0]
|
||||
//let uid = ck_info[0]
|
||||
//let deviceCode = ck_info[2]
|
||||
let user = {
|
||||
index: index,
|
||||
Authorization,
|
||||
//uid,
|
||||
//deviceCode,
|
||||
}
|
||||
index = index + 1 //每次用完序号+1
|
||||
//开始账号任务
|
||||
let Run = new run();
|
||||
await Run.userTask(user)
|
||||
//每个账号之间等1~5秒随机时间
|
||||
let rnd_time = Math.floor(Math.random() * 4000) + 1000
|
||||
console.log(`随机等待${rnd_time / 1000}秒...`)
|
||||
await $.wait(rnd_time)
|
||||
}
|
||||
}
|
||||
// ======================================开始任务=========================================
|
||||
class run {
|
||||
constructor(user) {
|
||||
@ -78,12 +35,14 @@ async userTask(user) {
|
||||
url: `https://webapi.qmai.cn/web/cmk-center/sign/takePartInSign`,
|
||||
headers: {
|
||||
"qm-from": "wechat",
|
||||
"qm-from-type": "catering",
|
||||
"qm-user-token": user.Authorization,
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090a13) XWEB/9129',
|
||||
},
|
||||
data:{
|
||||
"activityId": "983701274523176960",
|
||||
"appid": "wx3423ef0c7b7f19af"
|
||||
"activityId": "1123977036026589185",
|
||||
"appid": "wx3423ef0c7b7f19af",
|
||||
"version": "2"
|
||||
}
|
||||
}
|
||||
//
|
||||
@ -92,15 +51,18 @@ async userTask(user) {
|
||||
if (result?.status == true) {
|
||||
//打印签到结果
|
||||
DoubleLog(`🕊账号[${user.index}] 签到成功🎉`);
|
||||
}if(result?.data.sign == "false") {
|
||||
DoubleLog(`🕊账号[${user.index}] 签到失败:原因未知🚫`)
|
||||
}if (result?.status == false) {
|
||||
DoubleLog(`🕊账号[${user.index}] 签到失败:${result.message}🚫`)
|
||||
}else if(result?.data?.sign === "false") {
|
||||
DoubleLog(`🕊账号[${user.index}] 签到失败:原因未知🚫`);
|
||||
}else if (result?.status === false) {
|
||||
DoubleLog(`🕊账号[${user.index}] 签到失败:${result.message}🚫`);
|
||||
}else{
|
||||
DoubleLog(`🕊账号[${user.index}] 签到结果异常: `, JSON.stringify(result));
|
||||
}
|
||||
|
||||
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
//console.log(e);
|
||||
console.log(`🛑账号[${user.index}] 签到异常:`, e.message || e);
|
||||
}
|
||||
}
|
||||
//积分
|
||||
@ -135,6 +97,51 @@ async account(user) {
|
||||
}
|
||||
}
|
||||
}
|
||||
//==================================脚本入口函数main()==============================================================
|
||||
|
||||
async function main() {
|
||||
if (env == '') {
|
||||
//没有设置变量,直接退出
|
||||
console.log(`没有填写变量,请查看脚本说明: ${env_name}`)
|
||||
return
|
||||
}
|
||||
let user_ck = env.split('\n')
|
||||
DoubleLog(`\n========= 共找到 ${user_ck.length} 个账号 =========`);
|
||||
let index = 1 //用来给账号标记序号, 从1开始
|
||||
for (let ck of user_ck) {
|
||||
if (!ck) continue //跳过空行
|
||||
let ck_info = ck.split('&')
|
||||
let Authorization = ck_info[0]
|
||||
//let uid = ck_info[0]
|
||||
//let deviceCode = ck_info[2]
|
||||
let user = {
|
||||
index: index,
|
||||
Authorization,
|
||||
//uid,
|
||||
//deviceCode,
|
||||
}
|
||||
index = index + 1 //每次用完序号+1
|
||||
//开始账号任务
|
||||
let Run = new run();
|
||||
await Run.userTask(user)
|
||||
//每个账号之间等1~5秒随机时间
|
||||
let rnd_time = Math.floor(Math.random() * 4000) + 1000
|
||||
console.log(`随机等待${rnd_time / 1000}秒...`)
|
||||
await $.wait(rnd_time)
|
||||
}
|
||||
}
|
||||
|
||||
// ==================================异步顺序==============================================================================
|
||||
!(async () => {
|
||||
//await getNotice(); //远程通知
|
||||
//await getVersion("yang7758258/ohhh154@main/yybpc.js");
|
||||
await main();//主函数
|
||||
await SendMsg(msg); //发送通知
|
||||
|
||||
})()
|
||||
.catch((e) => $.logErr(e))
|
||||
.finally(() => $.done());
|
||||
|
||||
/**
|
||||
* =========================================================发送消息=============================================
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user