feet: 王五四文集 (#4081)

This commit is contained in:
prnake
2020-02-26 01:02:27 +08:00
committed by GitHub
parent 99d362794c
commit 2873b0b763
3 changed files with 41 additions and 0 deletions

View File

@@ -80,6 +80,14 @@ pageClass: routes
<Route author="kt286" example="/meituan/tech/home" path="/meituan/tech/home"/>
## 王五四文集
### 文章
<Route author="prnake" example="/blogs/wang54" path="/blogs/wang54/:id?" :paramsDesc="['RSS抓取地址https://wangwusiwj.blogspot.com/:id?默认为2020']">
</Route>
## 王垠博客
### 文章

View File

@@ -1280,6 +1280,9 @@ router.get('/blogs/jingwei.link', require('./routes/blogs/jingwei_link'));
// 王垠的博客-当然我在扯淡
router.get('/blogs/wangyin', require('./routes/blogs/wangyin'));
// 王五四文集
router.get('/blogs/wang54/:id?', require('./routes/blogs/wang54'));
// 裏垢女子まとめ
router.get('/uraaka-joshi', require('./routes/uraaka-joshi/uraaka-joshi'));
router.get('/uraaka-joshi/:id', require('./routes/uraaka-joshi/uraaka-joshi-user'));

View File

@@ -0,0 +1,30 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const id = ctx.params.id || 2020;
const url = `https://wangwusiwj.blogspot.com/${id}`;
const response = await got({ method: 'get', url });
const $ = cheerio.load(response.data);
const list = $('div.post')
.map((i, e) => ({
title: $(e)
.find('h3 > a')
.text(),
description: $(e)
.find('.post-body')
.html(),
link: $(e)
.find('h3 > a')
.attr('href'),
author: '王五四',
}))
.get();
ctx.state.data = {
title: '王五四文集',
link: url,
item: list,
};
};