From d27fc7c73ca549cc2e4ab07ed5c19ea2813a5031 Mon Sep 17 00:00:00 2001 From: nczitzk Date: Wed, 30 Dec 2020 08:02:57 +0800 Subject: [PATCH] feat: add anytxt release notes --- docs/en/program-update.md | 6 ++++++ docs/program-update.md | 6 ++++++ lib/router.js | 3 +++ lib/routes/anytxt/release-notes.js | 33 ++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 lib/routes/anytxt/release-notes.js diff --git a/docs/en/program-update.md b/docs/en/program-update.md index 9325fd5e2..7cdedfa42 100644 --- a/docs/en/program-update.md +++ b/docs/en/program-update.md @@ -10,6 +10,12 @@ pageClass: routes +## AnyTXT + +### Release Notes + + + ## Apkpure ### Versions diff --git a/docs/program-update.md b/docs/program-update.md index 5cddf1086..fc728ade9 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -20,6 +20,12 @@ pageClass: routes +## AnyTXT + +### Release Notes + + + ## Apkpure ### Versions diff --git a/lib/router.js b/lib/router.js index 5bb0f656c..7615efcb6 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3780,4 +3780,7 @@ router.get('/nace/blog/:sort?', require('./routes/nace/blog')); // Caixin Latest router.get('/caixin/latest', require('./routes/caixin/latest')); +// AnyTXT +router.get('/anytxt/release-notes', require('./routes/anytxt/release-notes')); + module.exports = router; diff --git a/lib/routes/anytxt/release-notes.js b/lib/routes/anytxt/release-notes.js new file mode 100644 index 000000000..da2ea9dcb --- /dev/null +++ b/lib/routes/anytxt/release-notes.js @@ -0,0 +1,33 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const rootUrl = 'https://anytxt.net'; + const currentUrl = `${rootUrl}/download`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const items = $('.has-medium-font-size') + .map((_, item) => { + item = $(item); + const date = item.text().replace(':', ''); + + return { + title: date, + link: currentUrl, + pubDate: new Date(date).toUTCString(), + description: `
    ${item.next().html()}
`, + }; + }) + .get(); + + ctx.state.data = { + title: 'Release Notes - AnyTXT', + link: currentUrl, + item: items, + }; +};