diff --git a/lib/v2/foresightnews/index.js b/lib/v2/foresightnews/index.js index d1d782624..a1e0267c6 100644 --- a/lib/v2/foresightnews/index.js +++ b/lib/v2/foresightnews/index.js @@ -1,6 +1,7 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const { parseDate } = require('@/utils/parse-date'); +const zlib = require('zlib'); const categories = { '': { @@ -28,12 +29,11 @@ module.exports = async (ctx) => { const rootUrl = 'https://foresightnews.pro'; const currentUrl = `${rootUrl}/v1/${categories[category].id}?page=1&size=${ctx.query.limit ?? 30}${category === 'column' ? `&column_id=${id}` : ''}`; - const response = await got({ - method: 'get', - url: currentUrl, - }); + const response = await got(currentUrl); - let items = response.data.data.list.map((item) => + const list = JSON.parse(zlib.inflateSync(Buffer.from(response.data.data.list, 'base64')).toString()); + + let items = list.map((item) => item.source_type ? { type: item.source_type, @@ -47,8 +47,8 @@ module.exports = async (ctx) => { : { type: category, title: item.title, - author: item?.author?.username ?? undefined, - link: `${rootUrl}/${category === 'article' ? 'article' : 'news'}/detail/${item.id}`, + author: item.author?.username ?? undefined, + link: `${rootUrl}/${category === 'article' || category === 'column' ? 'article' : 'news'}/detail/${item.id}`, category: item.tags ? item.tags.map((tag) => tag.name) : undefined, description: item.content ?? '', pubDate: parseDate(item.publishDate), @@ -63,10 +63,7 @@ module.exports = async (ctx) => { items.map((item) => ctx.cache.tryGet(item.link, async () => { if (item.type !== 'news') { - const detailResponse = await got({ - method: 'get', - url: item.link, - }); + const detailResponse = await got(item.link); const content = cheerio.load(detailResponse.data);