|  | 
| 本帖最后由 念。 于 2024-10-15 10:46 编辑 
 1、首先安装青龙面板(飞牛商店自带,不再赘述)
 
 2、进入青龙面板Web页面,跟随图示操作
 
 
 3、请检查是否安装过axios和cheerio依赖。检查方式如下图
 
 
 4、依赖安装完成后,编辑上述添加的js脚本文件,并粘贴复制以下代码
 
 
 复制代码const axios = require("axios");
const cheerio = require("cheerio");
// 填写对应的 Cookie 值
const cookies = {
    'pvRK_2132_saltkey': '*****',
    'pvRK_2132_auth': '*******',
};
const cookieHeader = Object.entries(cookies)
    .map(([key, value]) => `${key}=${value}`)
    .join("; ");
async function checkForNewReminders() {
    try {
        const response = await axios.get(
            "https://club.fnnas.com/home.php?mod=space&do=notice",
            { headers: { Cookie: cookieHeader } }
        );
        const $ = cheerio.load(response.data);
        // 检查是否有新提醒,通过检测 dd.ntc_body 的 style
        let hasNewReminders = false;
        $('.nts .cl .ntc_body').each((index, element) => {
            const styleAttr = $(element).attr('style');
            if (styleAttr && styleAttr.includes('color:#000;font-weight:bold;')) {
                hasNewReminders = true;
                return false; // 结束循环
            }
        });
        if (hasNewReminders) {
            console.log("有新提醒!");
            // 提取前五条信息
            const notifications = [];
            $('.nts .cl').slice(0, 5).each((index, element) => {
                const time = $(element).find('dt .xg1 span').first().text().trim();
                const timeStyled = `<span style="color: red;">${time}</span>`;
                const content = $(element).find('.ntc_body').text().trim();
                notifications.push(`${timeStyled}:${content}`);
            });
            if (notifications.length > 0) {
                console.log("前五条通知信息:");
                notifications.forEach((notification, index) => {
                    console.log(`${index + 1}: ${notification}`);
                });
                var notify = require("./sendNotify");
                await notify.sendNotify('飞牛论坛新提醒', notifications.join("\n"));
            }
        } else {
            console.log("没有新提醒");
        }
    } catch (error) {
        console.error("获取通知信息失败:", error);
    }
}
// 调用方法
checkForNewReminders();
 5、获取脚本中的'pvRK_2132_saltkey': '*****','pvRK_2132_auth': '********'
 去飞牛社区首页页面获取cookie,F12打开开发者模式,然后找到Network(网络)点击misc.php找到 浏览器不一样显示可能有点差异,如未找到请在控制台打开状态下刷新页面。
 
 
 6、获取到后,编辑脚本文件,并替换对应的值。
 7、进入定时任务页面添加新的定时任务
 
 
 8、添加完成后,手动运行一下进行测试。
 9、测试图
 
 
 结语:此举仅仅是为了更方便的去获取论坛的回复和提醒。建议大家不要设置较短间隔,以免对论坛服务器造成太大压力。
 
 
 
 
 | 
 
 
x本帖子中包含更多资源您需要 登录 才可以下载或查看,没有账号?立即注册  
 |