From 3c736f5beb2c04409a7fce7bbfed1ab53549d9bf Mon Sep 17 00:00:00 2001 From: Fatpandac <1779196284@qq.com> Date: Sun, 23 Jan 2022 03:50:03 +0800 Subject: [PATCH] add 423down (#8756) --- docs/bbs.md | 24 +++++ lib/v2/423down/index.js | 114 +++++++++++++++++++++ lib/v2/423down/maintainer.js | 3 + lib/v2/423down/radar.js | 193 +++++++++++++++++++++++++++++++++++ lib/v2/423down/router.js | 3 + 5 files changed, 337 insertions(+) create mode 100644 lib/v2/423down/index.js create mode 100644 lib/v2/423down/maintainer.js create mode 100644 lib/v2/423down/radar.js create mode 100644 lib/v2/423down/router.js diff --git a/docs/bbs.md b/docs/bbs.md index c069b9892..342f9eb95 100644 --- a/docs/bbs.md +++ b/docs/bbs.md @@ -64,6 +64,30 @@ pageClass: routes +## 423Down + +### 分类 + + + +| category | 全部 | +| :------: | :--: | +| index | all | + +| category | 安卓软件 | +| :------: | :------: | +| android | apk | + +| category | 原创软件 | 媒体播放 | 网页浏览 | 图形图像 | 聊天软件 | 办公软件 | 上传下载 | 系统辅助 | 系统必备 | 安全软件 | 补丁相关 | 硬件相关 | +| :------: | :----------: | :--------: | :------: | :------: | :------: | :------: | :------: | :--------: | :--------: | :------: | :------: | :------: | +| computer | originalsoft | multimedia | browser | image | im | work | down | systemsoft | systemplus | security | patch | hardware | + +| category | windows 11 | windows 10 | windows 7 | windows xp | windows pe | +| :------: | :--------: | :--------: | :-------: | :--------: | :--------: | +| os | win11 | win10 | win7 | winxp | winpe | + + + ## A 岛匿名版 ### 串 diff --git a/lib/v2/423down/index.js b/lib/v2/423down/index.js new file mode 100644 index 000000000..849da2e1f --- /dev/null +++ b/lib/v2/423down/index.js @@ -0,0 +1,114 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +const rootUrl = 'https://www.423down.com'; + +const categeoryMap = { + index: { + all: '', + }, + android: { + apk: 'apk', + }, + computer: { + originalsoft: 'zd423', + multimedia: 'multimedia', + browser: 'browser', + image: 'image', + im: 'im', + work: 'work', + down: 'down', + systemsoft: 'systemsoft', + systemplus: 'systemplus', + security: 'security', + patch: 'patch', + hardware: 'hardware', + }, + os: { + win11: 'win11', + win10: 'win10', + win7: 'win7', + winxp: 'winxp', + winpe: 'pe-system', + }, +}; + +const titleMap = { + index: { + all: '首页', + }, + android: { + apk: '安卓软件', + }, + computer: { + originalsoft: '原创软件', + multimedia: '媒体播放', + browser: '网页浏览', + image: '图形图像', + im: '聊天软件', + work: '办公软件', + down: '上传下载', + systemsoft: '系统辅助', + systemplus: '系统必备', + security: '安全软件', + patch: '补丁相关', + hardwork: '硬件相关', + }, + os: { + win11: 'windows 11', + win10: 'Windows 10', + win7: 'Windows 7', + winxp: 'Windows XP', + winpe: 'Windows PE', + }, +}; + +module.exports = async (ctx) => { + const { category, type } = ctx.params; + + const url = `${rootUrl}/${categeoryMap[category][type]}`; + + const response = await got.get(url); + const $ = cheerio.load(response.data); + const list = $('div.content-wrap > div > ul > li > a') + .filter((_, item) => { + const notAnotherWebPage = $(item).attr('style') !== 'display: none !important;'; + return notAnotherWebPage; + }) + .map((_, item) => ({ + link: $(item).attr('href'), + })) + .get(); + + const items = await Promise.all( + list.map(async (item) => { + item = await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got.get(item.link); + const $ = cheerio.load(detailResponse.data); + + const title = $('div.content-wrap > div > div.meta > h1 > a').text(); + const pageContent = $('div.content-wrap > div > div.entry').html(); + const pageComments = $('#postcomments > ol').html(); + const desc = pageContent + pageComments; + const date = $('div.content-wrap > div > div.meta > p').text(); + const categeory = $('div.content-wrap > div > div.meta > p > a:not(.comm)').text(); + + item.title = title; + item.description = desc; + item.categeory = categeory; + item.pubDate = parseDate(date.split(' ')[0], 'YYYY-MM-DD'); + + return item; + }); + + return item; + }) + ); + + ctx.state.data = { + title: `423down-${titleMap[category][type]}`, + link: url, + item: items, + }; +}; diff --git a/lib/v2/423down/maintainer.js b/lib/v2/423down/maintainer.js new file mode 100644 index 000000000..4d35f5c38 --- /dev/null +++ b/lib/v2/423down/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:category/:type': ['Fatpandac'], +}; diff --git a/lib/v2/423down/radar.js b/lib/v2/423down/radar.js new file mode 100644 index 000000000..a9aa9d31e --- /dev/null +++ b/lib/v2/423down/radar.js @@ -0,0 +1,193 @@ +module.exports = { + '423down.com': { + _name: '423down', + www: [ + { + title: '首页', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/', + target: '/423down/index/all', + }, + { + title: '安卓软件', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'apk') { + return '/423down/android/apk'; + } + }, + }, + { + title: '原创软件', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'zd423') { + return '/423down/computer/originalsoft'; + } + }, + }, + { + title: '媒体播放', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'multimedia') { + return '/423down/computer/multimedia'; + } + }, + }, + { + title: '网页浏览', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'browser') { + return '/423down/computer/browser'; + } + }, + }, + { + title: '图形图像', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'image') { + return '/423down/computer/image'; + } + }, + }, + { + title: '聊天软件', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'im') { + return '/423down/computer/im'; + } + }, + }, + { + title: '办公软件', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'work') { + return '/423down/computer/work'; + } + }, + }, + { + title: '上传下载', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'down') { + return '/423down/computer/down'; + } + }, + }, + { + title: '系统辅助', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'systemsoft') { + return '/423down/computer/systemsoft'; + } + }, + }, + { + title: '系统必备', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'systemplus') { + return '/423down/computer/systemplus'; + } + }, + }, + { + title: '安全软件', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'security') { + return '/423down/computer/security'; + } + }, + }, + { + title: '补丁相关', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'patch') { + return '/423down/computer/patch'; + } + }, + }, + { + title: '硬件相关', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'hardwork') { + return '/423down/computer/hardware'; + } + }, + }, + { + title: 'windows 11', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'win11') { + return '/423down/os/win11'; + } + }, + }, + { + title: 'windows 10', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'win10') { + return '/423down/os/win10'; + } + }, + }, + { + title: 'windows 7', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'win7') { + return '/423down/os/win7'; + } + }, + }, + { + title: 'windows xp', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'winxp') { + return '/423down/os/winxp'; + } + }, + }, + { + title: 'windows pe', + docs: 'https://docs.rsshub.app/bbs.html#_423down', + source: '/:type', + target: (params) => { + if (params.type === 'winpe') { + return '/423down/os/winpe'; + } + }, + }, + ], + }, +}; diff --git a/lib/v2/423down/router.js b/lib/v2/423down/router.js new file mode 100644 index 000000000..d520cef10 --- /dev/null +++ b/lib/v2/423down/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:category/:type?', require('./index')); +};