From bf50612ff35b52cd90792ba6878670f2d16bf0b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=85=E6=99=A8=E7=9A=84=E9=9B=BE?= <45256257+ret-1@users.noreply.github.com> Date: Fri, 25 Aug 2023 00:02:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(route):=20=E5=8D=97=E4=BA=AC=E5=A4=A7?= =?UTF-8?q?=E5=AD=A6=E7=A0=94=E7=A9=B6=E7=94=9F=E9=99=A2=20(#13116)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/nju/gra.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/v2/nju/gra.js b/lib/v2/nju/gra.js index 18d466feb..fc09613eb 100644 --- a/lib/v2/nju/gra.js +++ b/lib/v2/nju/gra.js @@ -6,26 +6,34 @@ const timezone = require('@/utils/timezone'); module.exports = async (ctx) => { const response = await got({ method: 'get', - url: 'https://grawww.nju.edu.cn/905/list1.htm', + url: 'https://grawww.nju.edu.cn/905/list.htm', }); const data = response.data; const $ = cheerio.load(data); - const list = $('li.list_item'); + const list = $('li.news'); ctx.state.data = { title: '研究生院-动态通知', - link: 'https://grawww.nju.edu.cn/905/list1.htm', + link: 'https://grawww.nju.edu.cn/905/list.htm', item: list .map((index, item) => { item = $(item); + + const year = item.find('.news_days').first().text(); + const day = item.find('.news_year').first().text(); // :) + if (!year.length || !day.length) { + return null; + } // 去掉友情链接 + return { title: item.find('a').attr('title'), link: 'https://grawww.nju.edu.cn' + item.find('a').attr('href'), - pubDate: timezone(parseDate(item.find('.Article_PublishDate').first().text(), 'YYYY-MM-DD'), +8), + pubDate: timezone(parseDate(year + day, 'YYYYMM-DD'), +8), }; }) - .get(), + .get() + .filter(Boolean), }; };