fix(route): 对外经济贸易大学人力资源处 (#8621)
This commit is contained in:
parent
b3b51cbc5d
commit
b04a5b8ff7
|
|
@ -16,30 +16,34 @@ module.exports = async (ctx) => {
|
|||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.lawul, .longul')
|
||||
let items = $('.lawul, .longul')
|
||||
.find('li a')
|
||||
.map((_, item) => {
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.find('p').text(),
|
||||
link: `${currentUrl}/${item.attr('href')}`,
|
||||
};
|
||||
})
|
||||
.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('.gp-article').html();
|
||||
item.pubDate = parseDate(content('#shareTitle').next().text().replace('时间:', ''));
|
||||
item.description = content('.gp-article').html();
|
||||
item.pubDate = parseDate(content('#shareTitle').next().text().replace('时间:', ''));
|
||||
} catch (err) {
|
||||
item.description = 'Not Found';
|
||||
}
|
||||
|
||||
return item;
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue