From 4e51922e192cb6632b00ba4cf2df49fb666ccacc Mon Sep 17 00:00:00 2001 From: DIYgod Date: Wed, 5 Sep 2018 18:21:33 +0800 Subject: [PATCH] rss: add xclient app --- docs/README.md | 12 ++++++++++++ router.js | 3 +++ routes/xclient/app.js | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 routes/xclient/app.js diff --git a/docs/README.md b/docs/README.md index 436e2c34b..673b272d3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1768,6 +1768,18 @@ GitHub 官方也提供了一些 RSS: - project: 项目的短名或者 `Project ID`. 项目的短名可以在地址栏获取到, 例如地址为 `https://minecraft.curseforge.com/projects/non-update`, 短名就为 `non-update`. `Project ID` 可在 `Overview` 中的 `About This Project` 中找到 +### xclient.info + +#### 应用更新 + +举例: + +路由: `/xclient/app/:name` + +参数: + +- name: 应用名,可在应用页 URL 中找到 + ## 大学通知 ### 上海海事大学 diff --git a/router.js b/router.js index 291386728..db2636288 100644 --- a/router.js +++ b/router.js @@ -530,4 +530,7 @@ router.get('/douyin/user/:id', require('./routes/douyin/user')); // 少数派 sspai router.get('/sspai/series', require('./routes/sspai/series')); +// xclient.info +router.get('/xclient/app/:name', require('./routes/xclient/app')); + module.exports = router; diff --git a/routes/xclient/app.js b/routes/xclient/app.js new file mode 100644 index 000000000..c18496130 --- /dev/null +++ b/routes/xclient/app.js @@ -0,0 +1,37 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const name = ctx.params.name; + + const response = await axios({ + method: 'get', + url: `http://xclient.info/s/${name}.html`, + }); + + const data = response.data; + + const $ = cheerio.load(data); + const list = $('#versions tbody tr'); + + ctx.state.data = { + title: $('title').text(), + link: `http://xclient.info/s/${name}.html`, + description: $('meta[name="description"]').attr('content') || $('title').text(), + item: + list && + list + .map((index, item) => { + item = $(item); + const td = item.find('td'); + return { + title: td.eq(0).text(), + description: `版本号:${td.eq(0).text()}
更新日期:${td.eq(2).text()}
文件大小:${td.eq(3).text()}`, + pubDate: new Date(td.eq(2).text()).toUTCString(), + link: `http://xclient.info/s/${name}.html`, + guid: td.eq(0).text(), + }; + }) + .get(), + }; +};