Files
RSSHub/lib/routes/tencent/wechat/ershcimi.js
2019-07-20 12:54:32 +08:00

28 lines
964 B
JavaScript

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,
};
};