diff --git a/lib/routes/universities/njtech/jwc.js b/lib/routes/universities/njtech/jwc.js index efce1e61e..31ce84e78 100644 --- a/lib/routes/universities/njtech/jwc.js +++ b/lib/routes/universities/njtech/jwc.js @@ -34,16 +34,20 @@ module.exports = async (ctx) => { } const response = await got.get(itemUrl); const $ = cheerio.load(response.data); - const single = { - title: $('#mainRight .title').text(), - link: itemUrl, - description: $('#vsb_content').html(), - pubDate: $('.time') - .text() - .match(/(\d{4}-\d{2})-\d{2}/)[0], - }; - ctx.cache.set(itemUrl, JSON.stringify(single)); - return Promise.resolve(single); + const targetDate = $('.time') + .text() + .match(/(\d{4}-\d{2})-\d{2}/); + + if (targetDate) { + const single = { + title: $('#mainRight .title').text(), + link: itemUrl, + description: $('#vsb_content').html(), + pubDate: targetDate[0], + }; + ctx.cache.set(itemUrl, JSON.stringify(single)); + return Promise.resolve(single); + } }) ); const info = '教务公告'; @@ -51,6 +55,6 @@ module.exports = async (ctx) => { ctx.state.data = { title: '南京工业大学教务处 - ' + info, link, - item: out, + item: out.filter((i) => i), }; };