Files
RSSHub/lib/routes/tencent/wechat/wemp.js
Henry Wang 21a7bf375c 增加虎嗅网用户文章 (#1462)
以及时区 timezone util 类
2019-01-29 19:16:36 +08:00

46 lines
1.2 KiB
JavaScript

const axios = require('../../../utils/axios');
const cheerio = require('cheerio');
const date = require('../../../utils/date');
module.exports = async (ctx) => {
const { id } = ctx.params;
const response = await axios.get(`https://wemp.app/accounts/${id}`);
const $ = cheerio.load(response.data);
const author = $('.mp-info__title')
.text()
.trim();
const year = new Date().getFullYear();
const items = $('.post-item__main')
.slice(0, 10)
.get()
.map((e) => ({
title: $(e)
.find('.post-item__title')
.text()
.trim(),
link: `https://wemp.app${$(e)
.find('.post-item__title')
.attr('href')}`,
pubDate: date(
`${year} ${$(e)
.find('.post-item__date')
.text()
.trim()}`,
8
),
author,
}));
ctx.state.data = {
title: `微信公众号 - ${author}`,
link: `https://wemp.app/accounts/${id}/`,
description: $('.mp-info__value')
.text()
.trim(),
item: items,
};
};