feat: add hex-rays news (#3726)

This commit is contained in:
hellodword
2020-01-14 12:02:11 +08:00
committed by DIYgod
parent 59756d27d4
commit 7968a8d1fb
3 changed files with 45 additions and 0 deletions

View File

@@ -154,6 +154,13 @@ GitHub 官方也提供了一些 RSS:
</Route>
## Hex-Rays
### Hex-Rays News
<Route author="hellodword" example="/hex-rays/news" path="/hex-rays/news">
</Route>
## ITSlide
### 最新

View File

@@ -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'));

View File

@@ -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
// 正文部分比较...乱且意义不大,所以没有正文