feat: 新增公主链接日服公告 (#3735)

This commit is contained in:
Saya
2020-01-14 12:19:20 +08:00
committed by DIYgod
parent 77388c8d9a
commit ed5b4a4c32
3 changed files with 43 additions and 0 deletions
+6
View File
@@ -362,3 +362,9 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
### 公告
<Route author="magic-akari" example="/kirara/news" path="/kirara/news"/>
## 公主链接
### 日服公告
<Route author="SayaSS" example="/pcr/news" path="/pcr/news"/>
+3
View File
@@ -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'));
+34
View File
@@ -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()}<br><img src="${itemPicUrl}">`,
link: item
.find('a')
.first()
.attr('href'),
pubDate: item.find('.time').text(),
};
})
.get(),
};
};