From 7968a8d1fb2e8d3bc79f7c6155057119a6429a60 Mon Sep 17 00:00:00 2001 From: hellodword <46193371+hellodword@users.noreply.github.com> Date: Tue, 14 Jan 2020 12:02:11 +0800 Subject: [PATCH] feat: add hex-rays news (#3726) --- docs/programming.md | 7 +++++++ lib/router.js | 3 +++ lib/routes/hex-rays/index.js | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 lib/routes/hex-rays/index.js diff --git a/docs/programming.md b/docs/programming.md index 21d13e499..fbecb26cb 100644 --- a/docs/programming.md +++ b/docs/programming.md @@ -154,6 +154,13 @@ GitHub 官方也提供了一些 RSS: +## Hex-Rays + +### Hex-Rays News + + + + ## ITSlide ### 最新 diff --git a/lib/router.js b/lib/router.js index c74ff79fe..e8134ee75 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2098,6 +2098,9 @@ router.get('/mlog-club/projects', require('./routes/mlog-club/projects')); // Chrome 网上应用店 router.get('/chrome/webstore/extensions/:id', require('./routes/chrome/extensions')); +// Hex-Rays News +router.get('/hex-rays/news', require('./routes/hex-rays/index')); + // 新趣集 router.get('/xinquji/today', require('./routes/xinquji/today')); router.get('/xinquji/today/internal', require('./routes/xinquji/internal')); diff --git a/lib/routes/hex-rays/index.js b/lib/routes/hex-rays/index.js new file mode 100644 index 000000000..9a5a81caa --- /dev/null +++ b/lib/routes/hex-rays/index.js @@ -0,0 +1,35 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + let host = 'https://www.hex-rays.com'; + + host = `${host}/news.shtml`; + + const response = await got.get(host); + + const $ = cheerio.load(response.data); + + const list = $('tr[bgcolor]'); + + ctx.state.data = { + title: 'Hex-Rays News', + link: host, + item: + list && + list + .map((index, item) => { + item = $(item); + return { + title: item.find('td:nth-child(1)').text() + ' ' + item.find('td:nth-child(2)').text(), + link: item.find('td:nth-child(2) > a').attr('href'), + }; + }) + .get(), + }; +}; + +// 虽然能够用插件探测到疑似feed,但是实际请求会发现需要登录 +// https://forum.hex-rays.com/app.php/feed/news + +// 正文部分比较...乱且意义不大,所以没有正文