* refactor: fix scut namespace * refactor: fix gzhu namespace * refactor: fix scnu namespace * refactor: fix hust namespace * refactor: fix ccnu namespace * refactor: fix sustech namespace * refactor: fix szu namespace remove `/szuyjs` since it's a duplicate of `/szu/yz/:type?` * refactor: fix tongji namespace * refactor: fix ocu namespace * refactor: fix upc namespace * refactor: fix ucas namespace * refactor: fix cas namespace * refactor: fix cau namespace * refactor: remove `/cucyjs` since `/cuc/yz` existed well before that * refactor: fix bit namespace * refactor: fix **undocumented** scau namespace * fix: typo * fix: code scan
26 lines
756 B
JavaScript
26 lines
756 B
JavaScript
const got = require('@/utils/got'); // get web content
|
|
const cheerio = require('cheerio'); // html parser
|
|
|
|
module.exports = async function getArticle(item) {
|
|
const response = await got({
|
|
method: 'get',
|
|
url: item.link,
|
|
});
|
|
const data = response.data;
|
|
|
|
const $ = cheerio.load(data);
|
|
const title = $('div.view-title').text();
|
|
const content = $('#vsb_content').html();
|
|
$('[name="_newscontent_fromname"] ul a').each((_, e) => {
|
|
const href = $(e).attr('href');
|
|
if (href.startsWith('/')) {
|
|
$(e).attr('href', new URL(href, item.link).href);
|
|
}
|
|
});
|
|
|
|
item.title = title;
|
|
item.description = content + ($('ul[style]').length ? $('ul[style]').html() : '');
|
|
|
|
return item;
|
|
};
|