feat: add 紫竹张先生 (#2187)

This commit is contained in:
Henry Wang
2019-05-22 03:49:38 +01:00
committed by DIYgod
parent 2bb9ae4be8
commit b27ed3ffd8
4 changed files with 67 additions and 12 deletions

View File

@@ -38,6 +38,12 @@ pageClass: routes
<Route author="GensouSakuya" example="/indienova/article" path="indienova/article"/>
## MaxNews
### Dota 2
<Route author="dearrrfish" example="/maxnews/dota2" path="maxnews/dota2" />
## Nintendo
### eShop 新发售游戏
@@ -198,9 +204,3 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
### 公告
<Route author="magic-akari" example="/kirara/news" path="/kirara/news"/>
## MaxNews
### Dota 2
<Route author="dearrrfish" example="/maxnews/dota2" path="maxnews/dota2" />

View File

@@ -416,12 +416,6 @@ type 为 all 时category 参数不支持 cost 和 free
<Route author="occupy5" example="/guanchazhe/topic/113" path="/guanchazhe/topic/:id" :paramsDesc="['话题id 可在URL中找到']" />
## 数英网
### 数英网最新文章
<Route author="occupy5" example="/digitaling/index" path="/digitaling/index" :paramsDesc="['首页最新文章, 数英网']" />
## 果壳网
### 科学人
@@ -686,6 +680,12 @@ type 为 all 时category 参数不支持 cost 和 free
<Route author="LogicJake" example="/who/news-room/feature-stories" path="/who/news-room/:type" :paramsDesc="['类别,可在 URL 中找到']"/>
## 数英网
### 数英网最新文章
<Route author="occupy5" example="/digitaling/index" path="/digitaling/index" :paramsDesc="['首页最新文章, 数英网']" />
## 刷屏
### 最新
@@ -846,3 +846,9 @@ type 为 all 时category 参数不支持 cost 和 free
### 房源
<Route author="DIYgod" example="/ziroom/room/sh/1/2/五角场" path="/ziroom/room/:city/:iswhole/:room/:keyword" :paramsDesc="['城市, 北京 bj; 上海 sh; 深圳 sz; 杭州 hz; 南京 nj; 广州 gz; 成都 cd; 武汉 wh; 天津 tj', '是否整租', '房间数', '关键词']"/>
## 紫竹张先生
### 全文
<Route author="HenryQW" example="/zzz" path="/zzz/index"/>

View File

@@ -1322,4 +1322,7 @@ router.get('/digitaling/index', require('./routes/digitaling/index'));
// Steamgifts
router.get('/steamgifts/discussions/:category?', require('./routes/steamgifts/discussions'));
// Steamgifts
router.get('/zzz', require('./routes/zzz/index'));
module.exports = router;

46
lib/routes/zzz/index.js Normal file
View File

@@ -0,0 +1,46 @@
const axios = require('@/utils/axios');
const cheerio = require('cheerio');
const Parser = require('rss-parser');
const parser = new Parser();
module.exports = async (ctx) => {
const feed = await parser.parseURL('https://z-z-z.vip/feed');
const ProcessFeed = (data) => {
const $ = cheerio.load(data);
const content = $('div.bpp-post-content');
content.find('img').each((i, e) => {
$(e).attr('src', $(e).attr('data-echo'));
});
return content.html();
};
const items = await Promise.all(
feed.items.map(async (item) => {
const response = await axios({
method: 'get',
url: item.link,
});
const single = {
guid: item.guid,
title: item.title,
description: ProcessFeed(response.data),
pubDate: item.pubDate,
link: item.link,
author: item['dc:creator'],
};
return Promise.resolve(single);
})
);
ctx.state.data = {
title: '紫竹张先生',
link: 'https://z-z-z.vip',
description: '紫竹张先生',
item: items,
};
};