@@ -29,7 +29,7 @@ module.exports = async (ctx) => {
|
||||
const date = new Date(`${info.slice(-2)[0]}T${info.slice(-1)[0]}`);
|
||||
const link = item.find('a').attr('href');
|
||||
const id = link.match(/content\/(\d+)/)[1];
|
||||
let description;
|
||||
let description = '';
|
||||
|
||||
if (id) {
|
||||
const key = `infzm: ${link}`;
|
||||
@@ -43,7 +43,22 @@ module.exports = async (ctx) => {
|
||||
url: `http://api.infzm.com/mobile/contents/${id}`,
|
||||
});
|
||||
|
||||
description = response.data.data.content.fulltext;
|
||||
if (response.data.code === 200) {
|
||||
description = response.data.data.content.fulltext;
|
||||
} else {
|
||||
// 有时候接口会返回未发布但实际已发布
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: `http://www.infzm.com/content/${id}`,
|
||||
headers: {
|
||||
Referer: url,
|
||||
Cookie: `PHPSESSID=${Math.floor(Math.random() * 100)};`,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
description = $('#content').html();
|
||||
}
|
||||
|
||||
ctx.cache.set(key, description, 24 * 60 * 60);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user