fix JSON.parse empty

This commit is contained in:
DIYgod
2018-06-15 14:29:09 +08:00
parent e6cebb3259
commit 58078a761e
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -29,9 +29,9 @@ module.exports = async (ctx) => {
const urlBase = url.replace(/.html/, '');
let total = 1;
const value = JSON.parse(await ctx.cache.get(url));
const value = await ctx.cache.get(url);
if (value) {
item = value;
item = JSON.parse(value);
} else {
// 抓取分页
for (let j = 1; ; j++) {
+2 -2
View File
@@ -23,9 +23,9 @@ module.exports = async (ctx) => {
const itemUrl = $(item)
.find('a:nth-child(2)')
.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 title = $(item)