diff --git a/docs/new-media.md b/docs/new-media.md index b59256e88..16d4f12e0 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -833,6 +833,29 @@ IPFS 网关有可能失效,那时候换成其他网关。 +## PANews + +### 深度 + + + +| DAO | 元宇宙 | DeFi | Layer 2 | 链游 | 波卡 | NFT | 央行数字货币 | 融资 | 活动 | 监管 | +| --- | ------ | ---- | ------- | ---- | ---- | --- | ------------ | ---- | ---- | ---- | + + + +### 快讯 + + + +### 专栏 + + + +### 专题 + + + ## PMCAFF ### 今日推荐 / 精选 diff --git a/lib/v2/panewslab/column.js b/lib/v2/panewslab/column.js new file mode 100644 index 000000000..5105e4f29 --- /dev/null +++ b/lib/v2/panewslab/column.js @@ -0,0 +1,60 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const id = ctx.params.id; + + const rootUrl = 'https://panewslab.com'; + const apiUrl = `${rootUrl}/api/newstopic/page`; + const currentUrl = `${rootUrl}/zh/author/${id}.html`; + + let author = ''; + + const response = await got({ + method: 'post', + url: apiUrl, + form: { + memberId: id, + language: 'zh', + pageIndex: 1, + pageSize: 25, + newsTopicState: 'PUBLISHED', + }, + }); + + let items = response.data.data.list.map((item) => { + author = item.nick_name; + return { + author, + title: item.title, + pubDate: parseDate(item.create_time), + link: `${rootUrl}/zh/articledetails/${item.id}.html`, + description: `
${item.remark}
`, + category: item.tags.split(','), + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + item.description += content('#txtinfo').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `PANews - ${author}`, + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/panewslab/index.js b/lib/v2/panewslab/index.js new file mode 100644 index 000000000..6afee6da6 --- /dev/null +++ b/lib/v2/panewslab/index.js @@ -0,0 +1,56 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const category = ctx.params.category ?? ''; + + const rootUrl = 'https://panewslab.com'; + const apiUrl = `${rootUrl}/api/newstopic/page`; + const currentUrl = `${rootUrl}/zh/profundity/index.html`; + + const response = await got({ + method: 'post', + url: apiUrl, + form: { + language: 'zh', + pageIndex: 1, + pageSize: 25, + newsTopicState: 'PUBLISHED', + isEssence: 'T', + tags: category, + }, + }); + + let items = response.data.data.list.map((item) => ({ + title: item.title, + author: item.nick_name, + pubDate: parseDate(item.create_time), + link: `${rootUrl}/zh/articledetails/${item.id}.html`, + description: `
${item.remark}
`, + category: item.tags.split(','), + })); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + item.description += content('#txtinfo').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `PANews - ${category || '精选'}`, + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/panewslab/maintainer.js b/lib/v2/panewslab/maintainer.js new file mode 100644 index 000000000..e97866430 --- /dev/null +++ b/lib/v2/panewslab/maintainer.js @@ -0,0 +1,6 @@ +module.exports = { + '/column/:id': ['nczitzk'], + '/newsflash/:language?': ['nczitzk'], + '/topic/:id': ['nczitzk'], + '/:category?': ['nczitzk'], +}; diff --git a/lib/v2/panewslab/newsflash.js b/lib/v2/panewslab/newsflash.js new file mode 100644 index 000000000..404262b9a --- /dev/null +++ b/lib/v2/panewslab/newsflash.js @@ -0,0 +1,35 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const language = ctx.params.language ?? 'zh'; + + const rootUrl = 'https://panewslab.com'; + const apiUrl = `${rootUrl}/api/sqtopic/pageBy`; + const currentUrl = `${rootUrl}/${language}/news/index.html`; + + const response = await got({ + method: 'post', + url: apiUrl, + form: { + language, + pageIndex: 1, + pageSize: 50, + topicState: 'PUBLISHED', + }, + }); + + const items = response.data.data.list[0].data.map((item) => ({ + title: item.title, + author: item.nick_name, + pubDate: parseDate(item.create_time), + link: `${rootUrl}/${language}/sqarticledetails/${item.id}.html`, + description: `

${item.content.replace(/来源链接$/, '').replace(/原文链接$/, '')}

`, + })); + + ctx.state.data = { + title: 'PANews - 快讯', + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/panewslab/radar.js b/lib/v2/panewslab/radar.js new file mode 100644 index 000000000..12d1fe4df --- /dev/null +++ b/lib/v2/panewslab/radar.js @@ -0,0 +1,31 @@ +module.exports = { + 'panewslab.com': { + _name: 'PANews', + '.': [ + { + title: '深度', + docs: 'https://docs.rsshub.app/new-media.html#panews-shen-du', + source: '/', + target: '/panewslab/:category?', + }, + { + title: '快讯', + docs: 'https://docs.rsshub.app/new-media.html#panews-kuai-xun', + source: '/', + target: '/panewslab/newsflash/:language?', + }, + { + title: '专栏', + docs: 'https://docs.rsshub.app/new-media.html#panews-zhuan-lan', + source: '/', + target: '/panewslab/column/:id', + }, + { + title: '专题', + docs: 'https://docs.rsshub.app/new-media.html#panews-zhuan-ti', + source: '/', + target: '/panewslab/topic/:id', + }, + ], + }, +}; diff --git a/lib/v2/panewslab/router.js b/lib/v2/panewslab/router.js new file mode 100644 index 000000000..f4a36673d --- /dev/null +++ b/lib/v2/panewslab/router.js @@ -0,0 +1,6 @@ +module.exports = function (router) { + router.get('/column/:id', require('./column')); + router.get('/newsflash/:language?', require('./newsflash')); + router.get('/topic/:id', require('./topic')); + router.get('/:category?', require('./index')); +}; diff --git a/lib/v2/panewslab/topic.js b/lib/v2/panewslab/topic.js new file mode 100644 index 000000000..dab1565c8 --- /dev/null +++ b/lib/v2/panewslab/topic.js @@ -0,0 +1,55 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const id = ctx.params.id; + + const rootUrl = 'https://panewslab.com'; + const apiUrl = `${rootUrl}/newstopic/pageH`; + const currentUrl = `${rootUrl}/zh/topiclist/${id}.html`; + + const response = await got({ + method: 'post', + url: apiUrl, + form: { + language: 'zh', + pageIndex: 1, + pageSize: 25, + newsThemeId: id, + newsTopicState: 'PUBLISHED', + }, + }); + + let items = response.data.data.list.map((item) => ({ + title: item.title, + author: item.nick_name, + pubDate: parseDate(item.create_time), + link: `${rootUrl}/zh/articledetails/${item.id}.html`, + description: `
${item.remark}
`, + category: item.tags.split(','), + })); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + item.description += content('#txtinfo').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `PANews - ${id}`, + link: currentUrl, + item: items, + }; +};