diff --git a/docs/new-media.md b/docs/new-media.md index 04f0fa83c..410056f86 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -2863,6 +2863,16 @@ column 为 third 时可选的 category: +## 链捕手 ChainCatcher + +### 首页 + + + +### 快讯 + + + ## 链新闻 ABMedia ### 首页最新新闻 diff --git a/lib/v2/chaincatcher/home.js b/lib/v2/chaincatcher/home.js new file mode 100644 index 000000000..47c363866 --- /dev/null +++ b/lib/v2/chaincatcher/home.js @@ -0,0 +1,50 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +const rootUrl = 'https://www.chaincatcher.com'; + +module.exports = async (ctx) => { + const { data } = await got.post(`${rootUrl}/api/article/lists`, { + form: { + page: 1, + home: 1, + }, + }); + + const list = data.data.map((item) => ({ + title: item.title, + description: item.description, + link: `${rootUrl}/article/${item.id}`, + pubDate: parseDate(item.add_time, 'X'), + categoryId: item.categoryid, + category: [...item.keywords.split(','), item.category_name], + })); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + if (item.categoryId !== 3) { + const { data: response } = await got(item.link); + const $ = cheerio.load(response); + item.description = art(path.join(__dirname, 'templates/home.art'), { + summary: item.description, + article: $('.article-container').html(), + }); + } + + return item; + }) + ) + ); + + ctx.state.data = { + title: '链捕手ChainCatcher — 专业的区块链技术研究与资讯平台-Chain Catcher', + description: '链捕手ChainCatcher为区块链技术爱好者与项目决策者提供NFT、Web3社交、DID、Layer2等专业的资讯与研究内容,Chain Catcher输出对Scroll、Sui、Aptos、ENS等项目的思考,拓宽读者对区块链与数字经济认知的边界。', + image: `${rootUrl}/logo.png`, + link: rootUrl, + item: items, + }; +}; diff --git a/lib/v2/chaincatcher/maintainer.js b/lib/v2/chaincatcher/maintainer.js new file mode 100644 index 000000000..f1c2d2dc1 --- /dev/null +++ b/lib/v2/chaincatcher/maintainer.js @@ -0,0 +1,4 @@ +module.exports = { + '/': ['TonyRL'], + '/news': ['TonyRL'], +}; diff --git a/lib/v2/chaincatcher/news.js b/lib/v2/chaincatcher/news.js new file mode 100644 index 000000000..ce26a243d --- /dev/null +++ b/lib/v2/chaincatcher/news.js @@ -0,0 +1,40 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +const rootUrl = 'https://www.chaincatcher.com'; + +module.exports = async (ctx) => { + const { data } = await got.post(`${rootUrl}/index/content/lists`, { + form: { + page: 1, + categoryid: 3, + }, + }); + + const $ = cheerio.load(data.data, null, false); + + $('.share').remove(); + const items = $('.block') + .toArray() + .map((item) => { + item = $(item); + item.find('.tips').remove(); + const act = !!item.find('.act-title').text(); + return { + title: `${act ? '[重] ' : ''}${item.find('.title').text()}`, + description: item.find('.summary').text(), + link: `${rootUrl}${item.find('a').first().attr('href')}`, + pubDate: timezone(parseDate(item.find('.time').text(), 'YYYY-MM-DD HH:mm:ss'), 8), + }; + }); + + ctx.state.data = { + title: '最新资讯-ChainCatcher', + description: '链捕手ChainCatcher为区块链技术爱好者与项目决策者提供NFT、Web3社交、DID、Layer2等专业的资讯与研究内容,Chain Catcher输出对Scroll、Sui、Aptos、ENS等项目的思考,拓宽读者对区块链与数字经济认知的边界。', + image: `${rootUrl}/logo.png`, + link: `${rootUrl}/news`, + item: items, + }; +}; diff --git a/lib/v2/chaincatcher/radar.js b/lib/v2/chaincatcher/radar.js new file mode 100644 index 000000000..47f28ab18 --- /dev/null +++ b/lib/v2/chaincatcher/radar.js @@ -0,0 +1,19 @@ +module.exports = { + 'chaincatcher.com': { + _name: '链捕手 ChainCatcher', + '.': [ + { + title: '首页', + docs: 'https://docs.rsshub.app/new-media.html#lian-bu-shou-chaincatcher', + source: ['/'], + target: '/chaincatcher', + }, + { + title: '快讯', + docs: 'https://docs.rsshub.app/new-media.html#lian-bu-shou-chaincatcher', + source: ['/news', '/'], + target: '/chaincatcher/news', + }, + ], + }, +}; diff --git a/lib/v2/chaincatcher/router.js b/lib/v2/chaincatcher/router.js new file mode 100644 index 000000000..a84cd0852 --- /dev/null +++ b/lib/v2/chaincatcher/router.js @@ -0,0 +1,4 @@ +module.exports = (router) => { + router.get('/', require('./home')); + router.get('/news', require('./news')); +}; diff --git a/lib/v2/chaincatcher/templates/home.art b/lib/v2/chaincatcher/templates/home.art new file mode 100644 index 000000000..9d419d8ad --- /dev/null +++ b/lib/v2/chaincatcher/templates/home.art @@ -0,0 +1,4 @@ +{{ if summary }} +
{{ summary }}

+{{ /if }} +{{@ article }}