fix: outdated route /hex-rays/news (#6508)
This commit is contained in:
parent
abcf932555
commit
decbb70e4d
|
|
@ -2,30 +2,23 @@ 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 link = 'https://www.hex-rays.com/blog/';
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('tr[bgcolor]');
|
||||
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 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(),
|
||||
title: 'Hex-Rays Blog',
|
||||
link,
|
||||
item,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue