mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-21 12:49:53 +08:00
fix: neunews (#4018)
This commit is contained in:
@@ -16,48 +16,49 @@ module.exports = async (ctx) => {
|
||||
const title = $('title').text();
|
||||
const items = $('.column-news-list > .news_list > .news > .news_title')
|
||||
.slice(0, 10)
|
||||
.children();
|
||||
const results = [];
|
||||
items.each(async (index, item) => {
|
||||
const label = $(item);
|
||||
const title = $(label).attr('title');
|
||||
const url = baseUrl + $(label).attr('href');
|
||||
const description = await ctx.cache.tryGet(url, async () => {
|
||||
const result = await got.get(url);
|
||||
const $ = cheerio.load(result.data);
|
||||
// 处理部分格式
|
||||
$('article')
|
||||
.find('span')
|
||||
.each(function() {
|
||||
const temp = $(this).text();
|
||||
$(this).replaceWith(temp);
|
||||
});
|
||||
$('article')
|
||||
.find('div')
|
||||
.each(function() {
|
||||
const temp = $(this).html();
|
||||
$(this).replaceWith(temp);
|
||||
});
|
||||
$('article')
|
||||
.find('a')
|
||||
.remove();
|
||||
$('article')
|
||||
.find('p')
|
||||
.each(function() {
|
||||
$(this).removeAttr('style');
|
||||
$(this).removeAttr('class');
|
||||
});
|
||||
return $('article').html();
|
||||
});
|
||||
const result = {
|
||||
title: title,
|
||||
description: description,
|
||||
link: url,
|
||||
};
|
||||
results.push(result);
|
||||
});
|
||||
.get();
|
||||
const results = await Promise.all(
|
||||
items.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const title = $('a').attr('title');
|
||||
const url = baseUrl + $('a').attr('href');
|
||||
const description = await ctx.cache.tryGet(url, async () => {
|
||||
const result = await got.get(url);
|
||||
const $ = cheerio.load(result.data);
|
||||
// 处理部分格式
|
||||
$('article')
|
||||
.find('span')
|
||||
.each(function() {
|
||||
const temp = $(this).text();
|
||||
$(this).replaceWith(temp);
|
||||
});
|
||||
$('article')
|
||||
.find('div')
|
||||
.each(function() {
|
||||
const temp = $(this).html();
|
||||
$(this).replaceWith(temp);
|
||||
});
|
||||
$('article')
|
||||
.find('a')
|
||||
.remove();
|
||||
$('article')
|
||||
.find('p')
|
||||
.each(function() {
|
||||
$(this).removeAttr('style');
|
||||
$(this).removeAttr('class');
|
||||
});
|
||||
return $('article').html();
|
||||
});
|
||||
const result = {
|
||||
title: title,
|
||||
description: description,
|
||||
link: url,
|
||||
};
|
||||
Promise.resolve(result);
|
||||
})
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: title,
|
||||
title: `东北大学新闻网-${title}`,
|
||||
item: results,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user