fix(route): 上海市药品监督管理局 (#10205)

This commit is contained in:
Ethan Shen 2022-07-13 20:02:38 +08:00 committed by GitHub
parent d8c3126570
commit 967492dcaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 8 deletions

View File

@ -21,25 +21,31 @@ module.exports = async (ctx) => {
.map((item) => {
item = $(item);
const link = item.attr('href');
return {
title: item.text(),
link: `${rootUrl}${item.attr('href')}`,
pubDate: parseDate(item.next().text()),
link: /^http/.test(link) ? link : `${rootUrl}${link}`,
};
});
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('#ivs_content').html();
item.pubDate = timezone(parseDate(content('meta[name="pubdate"]').attr('content')), +8);
item.description = content('#ivs_content').html();
item.pubDate = timezone(parseDate(content('meta[name="pubdate"]').attr('content')), +8);
} catch (e) {
// no-empty
}
return item;
})