diff --git a/lib/v2/36kr/index.js b/lib/v2/36kr/index.js index 463224ade0..1c33fd9908 100644 --- a/lib/v2/36kr/index.js +++ b/lib/v2/36kr/index.js @@ -27,16 +27,18 @@ module.exports = async (ctx) => { const data = JSON.parse(response.data.match(/"itemList":(\[.*?\])/)[1]); - let items = data.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 30).map((item) => { - item = item.templateMaterial ?? item; - return { - title: item.widgetTitle.replace(/<\/?em>/g, ''), - author: item.author, - pubDate: parseDate(item.publishTime), - link: `${rootUrl}/${path === '/newsflashes' ? 'newsflashes' : 'p'}/${item.itemId}`, - description: item.widgetContent ?? item.content, - }; - }); + let items = data.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 30) + .filter((item) => item.itemType !== 0) + .map((item) => { + item = item.templateMaterial ?? item; + return { + title: item.widgetTitle.replace(/<\/?em>/g, ''), + author: item.author, + pubDate: parseDate(item.publishTime), + link: `${rootUrl}/${path === '/newsflashes' ? 'newsflashes' : 'p'}/${item.itemId}`, + description: item.widgetContent ?? item.content, + }; + }); if (!/^\/(search|newsflashes)/.test(path)) { items = await Promise.all( @@ -47,20 +49,22 @@ module.exports = async (ctx) => { url: item.link, }); - const key = CryptoJS.enc.Utf8.parse('efabccee-b754-4c'); - const cipherText = detailResponse.data.match(/{"state":"(.*)","isEncrypt":true}/)[1]; - - const content = JSON.parse( - CryptoJS.AES.decrypt(cipherText, key, { + const cipherTextList = detailResponse.data.match(/{"state":"(.*)","isEncrypt":true}/) ?? []; + if (cipherTextList.length !== 0) { + const key = CryptoJS.enc.Utf8.parse('efabccee-b754-4c'); + const content = JSON.parse( + CryptoJS.AES.decrypt(cipherTextList[1], key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7, }) .toString(CryptoJS.enc.Utf8) .toString() - ).articleDetail.articleDetailData.data; - - item.description = content.widgetContent; - + ).articleDetail.articleDetailData.data; + item.description = content.widgetContent; + } else { + const $ = cheerio.load(detailResponse.body); + item.description = $('div.articleDetailContent').html(); + } return item; }) )