mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-01 17:48:15 +08:00
* feat(route): 添加 百度股市通 * fix: 修改 百度股市通 路径 * docs: 添加 百度股市通 文档 * feat: 添加 radar 支持 * fix: 按字母顺序插入新路由 * feat(route): 新增 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 * fix: 优化 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 的标题 * fix: 修复 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 部分情况下的非空判断 * fix: 修复 地区名称标题的问题 * fix: 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 的 guid 增加 pubDate * fix: 修复 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 guid 中添加 pubDate * fix: 修改 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 的 title * feat(route): 修复 HelloGitHub 的 月刊 路由 * fix: remove guid
51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
const got = require('@/utils/got');
|
|
const { art } = require('@/utils/render');
|
|
const path = require('path');
|
|
const md = require('markdown-it')({
|
|
html: true,
|
|
});
|
|
const cheerio = require('cheerio');
|
|
|
|
art.defaults.imports.render = function (string) {
|
|
return md.render(string);
|
|
};
|
|
|
|
module.exports = async (ctx) => {
|
|
const rootUrl = 'https://hellogithub.com';
|
|
const apiUrl = 'https://api.hellogithub.com/v1/periodical/';
|
|
|
|
const periodicalResponse = await got({
|
|
method: 'get',
|
|
url: apiUrl,
|
|
});
|
|
const current = periodicalResponse.data.volumes[0].num;
|
|
const currentUrl = `${rootUrl}/periodical/volume/${current}`;
|
|
const buildResponse = await got({
|
|
method: 'get',
|
|
url: currentUrl,
|
|
});
|
|
|
|
const $ = cheerio.load(buildResponse.data);
|
|
|
|
const text = $('#__NEXT_DATA__').text();
|
|
const response = JSON.parse(text);
|
|
const data = response.props;
|
|
const id = data.pageProps.volume.current_num;
|
|
|
|
const items = [
|
|
{
|
|
title: `No.${id}`,
|
|
link: `${rootUrl}/periodical/volume/${id}`,
|
|
description: art(path.join(__dirname, 'templates/volume.art'), {
|
|
data: data.pageProps.volume.data,
|
|
}),
|
|
},
|
|
];
|
|
|
|
ctx.state.data = {
|
|
title: 'HelloGithub - 月刊',
|
|
link: currentUrl,
|
|
item: items,
|
|
};
|
|
};
|