fix JSON.parse empty
This commit is contained in:
+2
-2
@@ -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++) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user