From 426d869bf0cd59b81f82fa14af6e822a2f5f70b1 Mon Sep 17 00:00:00 2001 From: cesaryuan <35998162+cesaryuan@users.noreply.github.com> Date: Tue, 28 Jul 2020 23:24:11 +0800 Subject: [PATCH] feat: add Quicker (#5259) Co-authored-by: root --- docs/bbs.md | 6 ++++++ docs/program-update.md | 6 ++++++ lib/router.js | 4 ++++ lib/routes/quicker/qa.js | 41 ++++++++++++++++++++++++++++++++++++ lib/routes/quicker/update.js | 30 ++++++++++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 lib/routes/quicker/qa.js create mode 100644 lib/routes/quicker/update.js diff --git a/docs/bbs.md b/docs/bbs.md index a801344008..72d8072509 100644 --- a/docs/bbs.md +++ b/docs/bbs.md @@ -118,6 +118,12 @@ pageClass: routes +## Quicker + +### 讨论区 + + + ## RF 技术社区 ### 文章 diff --git a/docs/program-update.md b/docs/program-update.md index a76784da54..173cf942eb 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -196,6 +196,12 @@ pageClass: routes 见 [#playstation](/game.html#playstation) +## Quicker + +### 版本更新 + + + ## RSSHub ### 有新路由啦 diff --git a/lib/router.js b/lib/router.js index 061e018b74..672e8945e4 100644 --- a/lib/router.js +++ b/lib/router.js @@ -42,6 +42,10 @@ router.get('/rsshub/sponsors', require('./routes/rsshub/sponsors')); // 1draw router.get('/1draw', require('./routes/1draw/index')); +// quicker +router.get('/quicker/qa', require('./routes/quicker/qa.js')); +router.get('/quicker/update', require('./routes/quicker/update.js')); + // bilibili router.get('/bilibili/user/video/:uid/:disableEmbed?', require('./routes/bilibili/video')); router.get('/bilibili/user/article/:uid', require('./routes/bilibili/article')); diff --git a/lib/routes/quicker/qa.js b/lib/routes/quicker/qa.js new file mode 100644 index 0000000000..183f902d6d --- /dev/null +++ b/lib/routes/quicker/qa.js @@ -0,0 +1,41 @@ +const cheerio = require('cheerio'); +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: 'https://getquicker.net/QA', + }); + const data = response.data; + const $ = cheerio.load(data); + const list = $('div.question-title > a'); + + const out = await Promise.all( + list + .map(async (index, item) => { + item = $(item); + const response_item = await got({ + method: 'get', + url: 'https://getquicker.net' + item.attr('href'), + }); + const a = cheerio.load(response_item.data); + return Promise.resolve({ + title: item.text(), + description: `作者:${a('.user-link').first().text()}
描述:${a('.user-content').first().html()}`, + pubDate: + a('.user-content span') + .last() + .text() + .match(/最后更新于\s*\S+/) || '1900/1/1', + link: item.attr('href'), + }); + }) + .get() + ); + + ctx.state.data = { + title: '讨论区 - Quicker', + link: 'https://getquicker.net/QA', + item: out, + }; +}; diff --git a/lib/routes/quicker/update.js b/lib/routes/quicker/update.js new file mode 100644 index 0000000000..e47b382e69 --- /dev/null +++ b/lib/routes/quicker/update.js @@ -0,0 +1,30 @@ +const cheerio = require('cheerio'); +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: 'https://getquicker.net/Help/Versions', + }); + const data = response.data; + const $ = cheerio.load(data); + const list = $('div.version-list > div'); + + const out = list + .map((index, item) => { + item = $(item); + return { + title: item.find('h2 > a').text(), + description: item.find('div.article-content').html(), + pubDate: item.find('div > span.text-secondary.d-lg-block.mb-2').text() || '1900/1/1', + link: item.find('h2 > a').attr('href'), + }; + }) + .get(); + + ctx.state.data = { + title: '版本更新 - Quicker', + link: 'https://getquicker.net/Help/Versions', + item: out, + }; +};