feat: nogizaka46 official website (#2710)

Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
David Zhang
2019-07-28 19:17:14 +08:00
committed by DIYgod
parent 031fcb0a9c
commit 8c1afe332f
3 changed files with 59 additions and 0 deletions

View File

@@ -689,6 +689,12 @@ type 为 all 时category 参数不支持 cost 和 free
<Route author="howel52" example="/jpmorganchase" path="/jpmorganchase"/>
## 乃木坂 46 官网
### 新闻
<Route author="crispgm" example="/nogizaka46/news" path="/nogizaka46/news" />
## 派代
### 首页

View File

@@ -1583,6 +1583,9 @@ router.get('/yidoutang/case/:type', require('./routes/yidoutang/case.js'));
// 开眼
router.get('/kaiyan/index', require('./routes/kaiyan/index'));
// 乃木坂46官网
router.get('/nogizaka46/news', require('./routes/nogizaka46/news'));
// 阿里云
router.get('/aliyun/database_month', require('./routes/aliyun/database_month'));

View File

@@ -0,0 +1,50 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'http://www.nogizaka46.com/news/',
headers: {
Referer: 'http://www.nogizaka46.com/',
},
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('#news #sheet div.left div.padding ul li');
ctx.state.data = {
allowEmpty: true,
title: '乃木坂46官网 NEWS',
link: 'http://www.nogizaka46.com/news/',
item:
list &&
list
.map((index, item) => {
item = $(item);
console.log(
item
.find('.title strong a')
.first()
.text()
);
return {
title: item
.find('.title strong a')
.first()
.text(),
description: item
.find('.summary')
.first()
.text(),
link: item.find('.title strong a').attr('href'),
pubDate: item
.find('.date')
.first()
.text(),
};
})
.get(),
};
};