fix(route): 中国人民大学人事处 (#8620)
This commit is contained in:
parent
b04a5b8ff7
commit
dff523d194
|
|
@ -15,29 +15,35 @@ module.exports = async (ctx) => {
|
|||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('a[title]')
|
||||
.map((_, item) => {
|
||||
let items = $('a[title]')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
const link = item.attr('href');
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${rootUrl}/${category}/${item.attr('href')}`,
|
||||
link: `${rootUrl}${link.indexOf('..') === 0 ? link.replace(/\.\./, '') : `/${category}/${link}`}`,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
try {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('.neirong').html();
|
||||
item.pubDate = parseDate(detailResponse.data.match(/日期:(\d{4}-\d{2}-\d{2})/)[1]);
|
||||
item.description = content('.neirong').html();
|
||||
item.pubDate = parseDate(detailResponse.data.match(/日期:(\d{4}-\d{2}-\d{2})/)[1]);
|
||||
} catch (err) {
|
||||
item.description = 'Not Found';
|
||||
}
|
||||
|
||||
return item;
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue