Skip to content

Commit

Permalink
修复新京报不显示文章内容的问题 (DIYgod#300)
Browse files Browse the repository at this point in the history
* Add 3dm news center.

* Modify router name, fix timezone issue.

* Add entries in Readme.
Add 新京报

* Fix an issue that may not show the content.

* Fix an issue that may not show the content.
  • Loading branch information
zhboner authored and DIYgod committed Jun 15, 2018
1 parent c9f8d37 commit e6cebb3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions routes/bjnews/news.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ module.exports = async (ctx) => {
time = $('p').text();
title = $('a').text();
itemUrl = $('a').attr('href');
const cache = JSON.parse(await ctx.cache.get(itemUrl));
const cache = await ctx.cache.get(itemUrl);
if (cache) {
out.push(cache);
out.push(JSON.parse(cache));
continue;
}
const single = {
Expand All @@ -33,7 +33,6 @@ module.exports = async (ctx) => {
guid: itemUrl,
};
out.push(single);
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
proList.push(axios_ins.get(itemUrl));
}
const responses = await axios.all(proList);
Expand All @@ -42,6 +41,7 @@ module.exports = async (ctx) => {
const data = res.data;
const $ = cheerio.load(data);
out[i].description = $('#main .content').html();
ctx.cache.set(out[i].link, JSON.stringify(out[i]), 24 * 60 * 60);
}
ctx.state.data = {
title: $('title').text(),
Expand Down

0 comments on commit e6cebb3

Please sign in to comment.