feat: 公众号增加二十次幂输出 (#2654)

This commit is contained in:
sanmmmm
2019-07-20 12:54:32 +08:00
committed by DIYgod
parent f0901c1c89
commit 26d08ee047
3 changed files with 32 additions and 0 deletions
+4
View File
@@ -682,6 +682,10 @@ pageClass: routes
<Route author="kt286" example="/wechat/uread/shensing" path="/wechat/uread/:userid" :paramsDesc="['公众号的微信号, 可在 微信-公众号-更多资料 中找到。并不是所有的都支持,能不能用随缘']"/>
### 公众号 (二十次幂来源)
<Route author="sanmmm" example="/wechat/ershicimi/59" path="/wechat/ershicimi/:id" :paramsDesc="['公众号id, 打开公众号页, 在 URL 中找到 id']"/>
### 公众平台系统公告栏目
<Route author="xyqfer" example="/wechat/announce" path="/wechat/announce" />
+1
View File
@@ -451,6 +451,7 @@ router.get('/wechat/announce', require('./routes/tencent/wechat/announce'));
router.get('/wechat/miniprogram/plugins', require('./routes/tencent/wechat/miniprogram/plugins'));
router.get('/wechat/tgchannel/:id', require('./routes/tencent/wechat/tgchannel'));
router.get('/wechat/uread/:userid', require('./routes/tencent/wechat/uread'));
router.get('/wechat/ershicimi/:id', require('./routes/tencent/wechat/ershcimi'));
// All the Flight Deals
router.get('/atfd/:locations/:nearby?', require('./routes/atfd/index'));
+27
View File
@@ -0,0 +1,27 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const { id } = ctx.params;
const url = `https://www.ershicimi.com/a/${id}`;
const response = await got(url);
const $ = cheerio.load(response.data);
const name = $('#wrapper > .yheader > .info-wrap .name').text();
const description = $('#wrapper .right > .Card .Profile-sideColumnItemValue').text();
const items = $('.weui_media_box')
.map((_, ele) => {
const $item = cheerio.load(ele);
return {
title: $item('.weui_media_title a').text(),
link: $item('.weui_media_title a').attr('href'),
pubDate: new Date($item('.weui_media_extra_info').attr('title')).toUTCString(),
};
})
.get();
ctx.state.data = {
title: `微信公众号 - ${name}`,
link: url,
description,
item: items,
};
};