diff --git a/docs/programming.md b/docs/programming.md index bacce0f36..4df15ad75 100644 --- a/docs/programming.md +++ b/docs/programming.md @@ -448,7 +448,7 @@ GitHub 官方也提供了一些 RSS: ### 月刊 - + ## Hex-Rays diff --git a/lib/v2/hellogithub/maintainer.js b/lib/v2/hellogithub/maintainer.js index 8bd65ccae..d4274cafc 100644 --- a/lib/v2/hellogithub/maintainer.js +++ b/lib/v2/hellogithub/maintainer.js @@ -5,5 +5,5 @@ module.exports = { '/month': ['moke8', 'nczitzk'], '/ranking/:type?': ['moke8', 'nczitzk'], '/report/:type?': ['nczitzk'], - '/volume': ['nczitzk'], + '/volume': ['nczitzk', 'CaoMeiYouRen'], }; diff --git a/lib/v2/hellogithub/volume.js b/lib/v2/hellogithub/volume.js index 6c3d11e0d..0c2ac5655 100644 --- a/lib/v2/hellogithub/volume.js +++ b/lib/v2/hellogithub/volume.js @@ -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'), {