feat(route): 修复 HelloGitHub 的 月刊 路由 (#11675)
* 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
This commit is contained in:
+1
-1
@@ -448,7 +448,7 @@ GitHub 官方也提供了一些 RSS:
|
||||
|
||||
### 月刊
|
||||
|
||||
<Route author="moke8 nczitzk" example="/hellogithub/volume" path="/hellogithub/volume"/>
|
||||
<Route author="moke8 nczitzk CaoMeiYouRen" example="/hellogithub/volume" path="/hellogithub/volume"/>
|
||||
|
||||
## Hex-Rays
|
||||
|
||||
|
||||
@@ -5,5 +5,5 @@ module.exports = {
|
||||
'/month': ['moke8', 'nczitzk'],
|
||||
'/ranking/:type?': ['moke8', 'nczitzk'],
|
||||
'/report/:type?': ['nczitzk'],
|
||||
'/volume': ['nczitzk'],
|
||||
'/volume': ['nczitzk', 'CaoMeiYouRen'],
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@ 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);
|
||||
@@ -11,28 +12,28 @@ art.defaults.imports.render = function (string) {
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://hellogithub.com';
|
||||
const currentUrl = `${rootUrl}/periodical/volume/`;
|
||||
const apiUrl = 'https://api.hellogithub.com/v1/periodical/';
|
||||
|
||||
const buildResponse = await got({
|
||||
method: 'get',
|
||||
url: rootUrl,
|
||||
});
|
||||
|
||||
const buildId = buildResponse.data.match(/"buildId":"(.*?)",/)[1];
|
||||
|
||||
const apiUrl = `${rootUrl}/_next/data/${buildId}/periodical/volume.json`;
|
||||
|
||||
const response = await got({
|
||||
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 data = response.data;
|
||||
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 = [
|
||||
{
|
||||
guid: id,
|
||||
title: `No.${id}`,
|
||||
link: `${rootUrl}/periodical/volume/${id}`,
|
||||
description: art(path.join(__dirname, 'templates/volume.art'), {
|
||||
|
||||
Reference in New Issue
Block a user