feat: filter out articles which require permission (#2698)

in NJTECH jwc
This commit is contained in:
TrumanGu
2019-07-27 11:49:03 +08:00
committed by DIYgod
parent fc7ce4aae7
commit f3cb9f458b
+15 -11
View File
@@ -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),
};
};