const axios = require('axios');
const cheerio = require('cheerio');
// 更新后的 Cookie 值
const cookies = {
'pvRK_2132_saltkey': '********',
'pvRK_2132_lastvisit': '***********'
};
// 将 Cookie 对象转换为 HTTP 请求头格式
const cookieHeader = Object.entries(cookies).map(([key, value]) => `${key}=${value}`).join('; ');
// 设置请求头
const headers = {
'Cookie': cookieHeader,
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36',
'Referer': 'https://club.fnnas.com/', // 网站的主页地址,可能需要根据您的实际情况进行修改
'X-Requested-With': 'XMLHttpRequest' // 有些网站需要这个字段
};
async function signIn() {
try {
// 发送签到请求
const response = await axios.get('https://club.fnnas.com/plugin.php?id=zqlj_sign&sign=25ef1716', {
headers: headers
});
if (response.data.includes('恭喜您,打卡成功!')) {
console.log('打卡成功');
await getSignInInfo();
} else if (response.data.includes('您今天已经打过卡了,请勿重复操作!')) {
console.log('已经打过卡了');
} else {
console.log('打卡失败, cookies可能已经过期或站点更新.');
}
} catch (error) {
console.error('签到请求失败:', error.response ? error.response.data : error.message);
}
}
async function getSignInInfo() {
try {
const response = await axios.get('https://club.fnnas.com/plugin.php?id=zqlj_sign', {
headers: headers
});
const $ = cheerio.load(response.data);
const content = [];
const patterns = [
{ name: '最近打卡', selector: 'li:contains("最近打卡")' },
{ name: '本月打卡', selector: 'li:contains("本月打卡")' },
{ name: '连续打卡', selector: 'li:contains("连续打卡")' },
{ name: '累计打卡', selector: 'li:contains("累计打卡")' },
{ name: '累计奖励', selector: 'li:contains("累计奖励")' },
{ name: '最近奖励', selector: 'li:contains("最近奖励")' },
{ name: '当前打卡等级', selector: 'li:contains("当前打卡等级")' }
];
patterns.forEach(pattern => {
const elements = $(pattern.selector);
if (elements.length > 0) {
const elementText = elements.text().replace(/.*:/, '').trim();
if (elementText) {
content.push(`${pattern.name}: ${elementText}`);
}
}
});
console.log(content.join('\n'));
} catch (error) {
console.error('获取打卡信息失败:', error.response ? error.response.data : error.message);
}
}
signIn();
|