fix: 本地宝丢弃过期链接 (#6472)
This commit is contained in:
parent
4fef6d4bc5
commit
27e3489fb6
|
|
@ -55,25 +55,30 @@ module.exports = async (ctx) => {
|
|||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({ method: 'get', url: item.link });
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
try {
|
||||
const detailResponse = await got({ method: 'get', url: item.link });
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
// Some links lead to mobile-view pages.
|
||||
// eg. http://m.bj.bendibao.com/news/273517.html
|
||||
// Divs for contents are different from which in desktop-view pages.
|
||||
// Some links lead to mobile-view pages.
|
||||
// eg. http://m.bj.bendibao.com/news/273517.html
|
||||
// Divs for contents are different from which in desktop-view pages.
|
||||
|
||||
item.description = content('div.content').html() ? content('div.content').html() : content('div.content-box').html();
|
||||
item.description = content('div.content').html() || content('div.content-box').html();
|
||||
|
||||
// Spans for publish dates are the same cases as above.
|
||||
// Spans for publish dates are the same cases as above.
|
||||
|
||||
item.pubDate = new Date((content('span.time').text() ? content('span.time').text().replace(/发布时间:/, '') : content('span.public_time').text()) + ' GMT+8').toUTCString();
|
||||
return item;
|
||||
item.pubDate = new Date((content('span.time').text().replace(/发布时间:/, '') || content('span.public_time').text()) + ' GMT+8').toUTCString();
|
||||
|
||||
return item;
|
||||
} catch (e) {
|
||||
return Promise.resolve('');
|
||||
}
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: title,
|
||||
title,
|
||||
link: `http://${city}.bendibao.com/`,
|
||||
item: items,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue