fix: caixin article json (#4126)

This commit is contained in:
hoilc 2020-03-01 12:29:53 +08:00 committed by GitHub
parent 043c1e4379
commit 2c13d144b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -3,16 +3,14 @@ const got = require('@/utils/got');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'http://mapiv5.caixin.com//m/api/getWapIndexListByPage?page=1&callback=jQuery213030389065931348935_1560140003113&_=1560140003179',
url: 'http://mapiv5.caixin.com//m/api/getWapIndexListByPage?page=1&callback=&_=1560140003179',
headers: {
Referer: `http://mapiv5.caixin.com/`,
Host: 'mapiv5.caixin.com',
},
});
const reg = /(.*jQuery.*\()([\s\S]*)(\))/;
const datatmp = response.data.replace(reg, '$2');
const data = JSON.parse(datatmp).data.list;
const data = response.data.data.list;
ctx.state.data = {
title: `财新网 - 首页`,
@ -20,8 +18,9 @@ module.exports = async (ctx) => {
description: '财新网 - 首页',
item: data.map((item) => ({
title: item.title,
description: item.summary,
description: `<p>${item.summary}</p><img src="${item.pics}">`,
link: item.web_url,
pubDate: new Date(item.time * 1000),
})),
};
};