fix(route): hex-rays news pubDate and author (#8202)
This commit is contained in:
parent
f2a2d11268
commit
27cff2bf43
|
|
@ -2506,8 +2506,8 @@ router.get('/galaxylab', lazyloadRouteHandler('./routes/galaxylab/index'));
|
|||
// NOSEC 安全讯息平台
|
||||
router.get('/nosec/:keykind?', lazyloadRouteHandler('./routes/nosec/index'));
|
||||
|
||||
// Hex-Rays News
|
||||
router.get('/hex-rays/news', lazyloadRouteHandler('./routes/hex-rays/index'));
|
||||
// Hex-Rays News migrated to v2
|
||||
// router.get('/hex-rays/news', lazyloadRouteHandler('./routes/hex-rays/index'));
|
||||
|
||||
// 新趣集
|
||||
router.get('/xinquji/today', lazyloadRouteHandler('./routes/xinquji/today'));
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = 'https://www.hex-rays.com/blog/';
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const item = $('.post-list-container')
|
||||
.map((index, ele) => ({
|
||||
title: $('h3 > a', ele).text(),
|
||||
link: $('h3 > a', ele).attr('href'),
|
||||
pubDate: new Date($('.post-meta:nth-of-type(1)', ele).text().trim().replace('Posted on:', '')),
|
||||
author: $('.post-meta:nth-of-type(2)', ele).text().trim(),
|
||||
}))
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Hex-Rays Blog',
|
||||
link,
|
||||
item,
|
||||
};
|
||||
};
|
||||
|
||||
// 虽然能够用插件探测到疑似feed,但是实际请求会发现需要登录
|
||||
// https://forum.hex-rays.com/app.php/feed/news
|
||||
|
||||
// 正文部分比较...乱且意义不大,所以没有正文
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = 'https://www.hex-rays.com/blog/';
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.post-list-container')
|
||||
.map((_, ele) => ({
|
||||
title: $('h3 > a', ele).text(),
|
||||
link: $('h3 > a', ele).attr('href'),
|
||||
pubDate: parseDate($('.post-meta:nth-of-type(1)', ele).first().text().trim().replace('Posted on:', '')),
|
||||
author: $('.post-meta:nth-of-type(2)', ele).first().text().replace('By:', '').trim(),
|
||||
}))
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got.get(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.category = (
|
||||
content('.category-link')
|
||||
.toArray()
|
||||
.map((e) => $(e).text()) +
|
||||
',' +
|
||||
content('.tag-link')
|
||||
.toArray()
|
||||
.map((e) => $(e).text())
|
||||
).split(',');
|
||||
|
||||
item.description = content('.post-content').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Hex-Rays Blog',
|
||||
link,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/news': ['hellodword ', 'TonyRL'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'hex-rays.com': {
|
||||
_name: 'Hex-Rays',
|
||||
'.': [
|
||||
{
|
||||
title: 'Hex-Rays News',
|
||||
docs: 'https://docs.rsshub.app/programming.html#hex-rays',
|
||||
source: ['/', '/blog'],
|
||||
target: '/hex-rays/news',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/news', require('./index'));
|
||||
};
|
||||
Loading…
Reference in New Issue