From ed5b4a4c324f2131426f7ed562da523ff5378d2e Mon Sep 17 00:00:00 2001 From: Saya <45657386+SayaSS@users.noreply.github.com> Date: Tue, 14 Jan 2020 12:19:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=85=AC=E4=B8=BB?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E6=97=A5=E6=9C=8D=E5=85=AC=E5=91=8A=20(#3735?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/game.md | 6 ++++++ lib/router.js | 3 +++ lib/routes/pcr/news.js | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 lib/routes/pcr/news.js diff --git a/docs/game.md b/docs/game.md index d02cf6a6ff..d5fc3f5f1d 100644 --- a/docs/game.md +++ b/docs/game.md @@ -362,3 +362,9 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 ### 公告 + +## 公主链接 + +### 日服公告 + + diff --git a/lib/router.js b/lib/router.js index b9f8bf7031..4498ff182e 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2098,6 +2098,9 @@ router.get('/mlog-club/projects', require('./routes/mlog-club/projects')); // Chrome 网上应用店 router.get('/chrome/webstore/extensions/:id', require('./routes/chrome/extensions')); +// 公主链接日服公告 +router.get('/pcr/news', require('./routes/pcr/news')); + // project-zero issues router.get('/project-zero-issues', require('./routes/project-zero-issues/index')); diff --git a/lib/routes/pcr/news.js b/lib/routes/pcr/news.js new file mode 100644 index 0000000000..691db8d913 --- /dev/null +++ b/lib/routes/pcr/news.js @@ -0,0 +1,34 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: 'https://priconne-redive.jp/news/', + }); + const data = response.data; + const $ = cheerio.load(data); + const list = $('.article_box'); + let itemPicUrl; + ctx.state.data = { + title: '公主链接日服-新闻', + link: 'https://priconne-redive.jp/news/', + item: + list && + list + .map((index, item) => { + item = $(item); + itemPicUrl = item.find('img.attachment-news-thumbnail').attr('src'); + return { + title: item.find('h4').text(), + description: `${item.find('.description p').text()}
`, + link: item + .find('a') + .first() + .attr('href'), + pubDate: item.find('.time').text(), + }; + }) + .get(), + }; +};