From 851f4267d1c07da27c340dc5d7cc2159679e8b37 Mon Sep 17 00:00:00 2001 From: Ethan Shen <42264778+nczitzk@users.noreply.github.com> Date: Mon, 11 Sep 2023 00:08:56 +0800 Subject: [PATCH] feat(route): add 8264 (#13239) * feat(route): add 8264 * fix typo * fix pubDate * fix: move to bbs --------- --- lib/v2/8264/list.js | 92 +++++++ lib/v2/8264/maintainer.js | 3 + lib/v2/8264/radar.js | 355 ++++++++++++++++++++++++++ lib/v2/8264/router.js | 3 + lib/v2/8264/templates/description.art | 5 + website/docs/routes/bbs.md | 67 +++++ website/docs/routes/new-media.md | 1 + 7 files changed, 526 insertions(+) create mode 100644 lib/v2/8264/list.js create mode 100644 lib/v2/8264/maintainer.js create mode 100644 lib/v2/8264/radar.js create mode 100644 lib/v2/8264/router.js create mode 100644 lib/v2/8264/templates/description.art diff --git a/lib/v2/8264/list.js b/lib/v2/8264/list.js new file mode 100644 index 000000000..50386dd84 --- /dev/null +++ b/lib/v2/8264/list.js @@ -0,0 +1,92 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const iconv = require('iconv-lite'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const { id = '751' } = ctx.params; + const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30; + + const rootUrl = 'https://www.8264.com'; + const currentUrl = new URL(`list/${id}`, rootUrl).href; + + const { data: response } = await got(currentUrl, { + responseType: 'buffer', + }); + + const $ = cheerio.load(iconv.decode(response, 'gbk')); + + $('div.newslist_info').remove(); + + let items = $('div.newlist_r, div.newslist_r, div.bbslistone_name, dt') + .find('a') + .slice(0, limit) + .toArray() + .map((item) => { + item = $(item); + + const link = item.prop('href'); + + return { + title: item.text(), + link: /^http/.test(link) ? link : new URL(link, rootUrl).href, + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const { data: detailResponse } = await got(item.link, { + responseType: 'buffer', + }); + + const content = cheerio.load(iconv.decode(detailResponse, 'gbk')); + + content('a.syq, a.xlsj, a.titleoverflow200, #fjump').remove(); + content('i.pstatus').remove(); + content('div.crly').remove(); + + const pubDate = content('span.pub-time').text() || content('span.fby span').first().prop('title') || content('span.fby').first().text().split('发表于').pop().trim(); + + content('img').each(function () { + content(this).replaceWith( + art(path.join(__dirname, 'templates/description.art'), { + image: { + src: content(this).prop('file'), + alt: content(this).prop('alt'), + }, + }) + ); + }); + + item.title = content('h1').first().text(); + item.description = content('div.art-content, td.t_f').first().html(); + item.author = content('a.user-name, #author').first().text(); + item.category = content('div.fl_dh a, div.site a') + .toArray() + .map((c) => content(c).text().trim()); + item.pubDate = timezone(parseDate(pubDate, ['YYYY-MM-DD HH:mm', 'YYYY-M-D HH:mm']), +8); + + return item; + }) + ) + ); + + const description = $('meta[name="description"]').prop('content').trim(); + const icon = new URL('favicon', rootUrl).href; + + ctx.state.data = { + item: items, + title: `${$('span.country, h2').text()} - ${description.split(',').pop()}`, + link: currentUrl, + description, + language: 'zh-cn', + icon, + logo: icon, + subtitle: $('meta[name="keywords"]').prop('content').trim(), + author: $('meta[name="author"]').prop('content'), + }; +}; diff --git a/lib/v2/8264/maintainer.js b/lib/v2/8264/maintainer.js new file mode 100644 index 000000000..53c1595b2 --- /dev/null +++ b/lib/v2/8264/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/list/:id?': ['nczitzk'], +}; diff --git a/lib/v2/8264/radar.js b/lib/v2/8264/radar.js new file mode 100644 index 000000000..e46f2102f --- /dev/null +++ b/lib/v2/8264/radar.js @@ -0,0 +1,355 @@ +module.exports = { + '8264.com': { + _name: '8264', + '.': [ + { + title: '热门推荐', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/751'], + target: '/8264/list/751', + }, + { + title: '户外知识', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/238'], + target: '/8264/list/238', + }, + { + title: '户外装备', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/204'], + target: '/8264/list/204', + }, + { + title: '业界', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/489'], + target: '/8264/list/489', + }, + { + title: '国际', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/733'], + target: '/8264/list/733', + }, + { + title: '专访', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/746'], + target: '/8264/list/746', + }, + { + title: '图说', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/902'], + target: '/8264/list/902', + }, + { + title: '户外', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/914'], + target: '/8264/list/914', + }, + { + title: '登山', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/934'], + target: '/8264/list/934', + }, + { + title: '攀岩', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/935'], + target: '/8264/list/935', + }, + { + title: '徒步', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/242'], + target: '/8264/list/242', + }, + { + title: '露营', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/950'], + target: '/8264/list/950', + }, + { + title: '安全急救', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/931'], + target: '/8264/list/931', + }, + { + title: '领队', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/920'], + target: '/8264/list/920', + }, + { + title: '登雪山', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/915'], + target: '/8264/list/915', + }, + { + title: '攀岩', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/916'], + target: '/8264/list/916', + }, + { + title: '骑行', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/917'], + target: '/8264/list/917', + }, + { + title: '跑步', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/918'], + target: '/8264/list/918', + }, + { + title: '滑雪', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/919'], + target: '/8264/list/919', + }, + { + title: '水上运动', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/921'], + target: '/8264/list/921', + }, + { + title: '钓鱼', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/951'], + target: '/8264/list/951', + }, + { + title: '潜水', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/952'], + target: '/8264/list/952', + }, + { + title: '攀冰', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/953'], + target: '/8264/list/953', + }, + { + title: '冲浪', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/966'], + target: '/8264/list/966', + }, + { + title: '网球', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/967'], + target: '/8264/list/967', + }, + { + title: '绳索知识', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/968'], + target: '/8264/list/968', + }, + { + title: '高尔夫', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/969'], + target: '/8264/list/969', + }, + { + title: '马术', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/970'], + target: '/8264/list/970', + }, + { + title: '户外摄影', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/973'], + target: '/8264/list/973', + }, + { + title: '羽毛球', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/971'], + target: '/8264/list/971', + }, + { + title: '游泳', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/974'], + target: '/8264/list/974', + }, + { + title: '溯溪', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/975'], + target: '/8264/list/975', + }, + { + title: '健身', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/976'], + target: '/8264/list/976', + }, + { + title: '瑜伽', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/977'], + target: '/8264/list/977', + }, + { + title: '服装', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/209'], + target: '/8264/list/209', + }, + { + title: '冲锋衣', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/923'], + target: '/8264/list/923', + }, + { + title: '抓绒衣', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/924'], + target: '/8264/list/924', + }, + { + title: '皮肤衣', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/925'], + target: '/8264/list/925', + }, + { + title: '速干衣', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/926'], + target: '/8264/list/926', + }, + { + title: '羽绒服', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/927'], + target: '/8264/list/927', + }, + { + title: '软壳', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/929'], + target: '/8264/list/929', + }, + { + title: '户外鞋', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/211'], + target: '/8264/list/211', + }, + { + title: '登山鞋', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/928'], + target: '/8264/list/928', + }, + { + title: '徒步鞋', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/930'], + target: '/8264/list/930', + }, + { + title: '越野跑鞋', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/933'], + target: '/8264/list/933', + }, + { + title: '溯溪鞋', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/932'], + target: '/8264/list/932', + }, + { + title: '登山杖', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/220'], + target: '/8264/list/220', + }, + { + title: '帐篷', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/208'], + target: '/8264/list/208', + }, + { + title: '睡袋', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/212'], + target: '/8264/list/212', + }, + { + title: '炉具', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/792'], + target: '/8264/list/792', + }, + { + title: '灯具', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/218'], + target: '/8264/list/218', + }, + { + title: '水具', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/219'], + target: '/8264/list/219', + }, + { + title: '面料', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/222'], + target: '/8264/list/222', + }, + { + title: '背包', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/207'], + target: '/8264/list/207', + }, + { + title: '防潮垫', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/214'], + target: '/8264/list/214', + }, + { + title: '电子导航', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/216'], + target: '/8264/list/216', + }, + { + title: '冰岩绳索', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/215'], + target: '/8264/list/215', + }, + { + title: '综合装备', + docs: 'https://docs.rsshub.app/routes/new-media#8264-lie-biao', + source: ['/list/223'], + target: '/8264/list/223', + }, + ], + }, +}; diff --git a/lib/v2/8264/router.js b/lib/v2/8264/router.js new file mode 100644 index 000000000..9b1fb8a0f --- /dev/null +++ b/lib/v2/8264/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/list/:id?', require('./list')); +}; diff --git a/lib/v2/8264/templates/description.art b/lib/v2/8264/templates/description.art new file mode 100644 index 000000000..f8634a8a2 --- /dev/null +++ b/lib/v2/8264/templates/description.art @@ -0,0 +1,5 @@ +{{ if image }} +
+ {{ image.alt }} +
+{{ /if }} \ No newline at end of file diff --git a/website/docs/routes/bbs.md b/website/docs/routes/bbs.md index f56801f74..8778fa480 100644 --- a/website/docs/routes/bbs.md +++ b/website/docs/routes/bbs.md @@ -108,6 +108,73 @@ +## 8264 {#8264} + +### 列表 {#8264-lie-biao} + + + +| 热门推荐 | 户外知识 | 户外装备 | +| -------- | -------- | -------- | +| 751 | 238 | 204 | + +
+ 更多列表 + +#### 热门推荐 + + | 业界 | 国际 | 专访 | 图说 | 户外 | 登山 | 攀岩 | + | ---- | ---- | ---- | ---- | ---- | ---- | ---- | + | 489 | 733 | 746 | 902 | 914 | 934 | 935 | + +#### 户外知识 + + | 徒步 | 露营 | 安全急救 | 领队 | 登雪山 | + | ---- | ---- | -------- | ---- | ------ | + | 242 | 950 | 931 | 920 | 915 | + + | 攀岩 | 骑行 | 跑步 | 滑雪 | 水上运动 | + | ---- | ---- | ---- | ---- | -------- | + | 916 | 917 | 918 | 919 | 921 | + + | 钓鱼 | 潜水 | 攀冰 | 冲浪 | 网球 | + | ---- | ---- | ---- | ---- | ---- | + | 951 | 952 | 953 | 966 | 967 | + + | 绳索知识 | 高尔夫 | 马术 | 户外摄影 | 羽毛球 | + | -------- | ------ | ---- | -------- | ------ | + | 968 | 969 | 970 | 973 | 971 | + + | 游泳 | 溯溪 | 健身 | 瑜伽 | + | ---- | ---- | ---- | ---- | + | 974 | 975 | 976 | 977 | + +#### 户外装备 + + | 服装 | 冲锋衣 | 抓绒衣 | 皮肤衣 | 速干衣 | + | ---- | ------ | ------ | ------ | ------ | + | 209 | 923 | 924 | 925 | 926 | + + | 羽绒服 | 软壳 | 户外鞋 | 登山鞋 | 徒步鞋 | + | ------ | ---- | ------ | ------ | ------ | + | 927 | 929 | 211 | 928 | 930 | + + | 越野跑鞋 | 溯溪鞋 | 登山杖 | 帐篷 | 睡袋 | + | -------- | ------ | ------ | ---- | ---- | + | 933 | 932 | 220 | 208 | 212 | + + | 炉具 | 灯具 | 水具 | 面料 | 背包 | + | ---- | ---- | ---- | ---- | ---- | + | 792 | 218 | 219 | 222 | 207 | + + | 防潮垫 | 电子导航 | 冰岩绳索 | 综合装备 | + | ------ | -------- | -------- | -------- | + | 214 | 216 | 215 | 223 | + +
+ +
+ ## Chiphell {#chiphell} ### 子版块 {#chiphell-zi-ban-kuai} diff --git a/website/docs/routes/new-media.md b/website/docs/routes/new-media.md index 45d7fb7a0..971c443e6 100644 --- a/website/docs/routes/new-media.md +++ b/website/docs/routes/new-media.md @@ -125,6 +125,7 @@ + ## 9To5 {#9to5} ### 9To5 Sub-site {#9to5-9to5-sub-site}