mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
Fix seu (#1323)
fix #1316 * 计算机技术与工程学院rss正常 * 信息科学与工程学院学术活动最新一期跳转到了微信文章,加了判断
This commit is contained in:
@@ -10,14 +10,24 @@ module.exports = async (ctx) => {
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.Article_Title a')
|
||||
const list = $('.list_item')
|
||||
.slice(0, 10)
|
||||
.map((i, e) => $(e).attr('href'))
|
||||
.map(function() {
|
||||
const info = {
|
||||
link: $(this)
|
||||
.find('div:nth-child(1) span.Article_Title a')
|
||||
.attr('href'),
|
||||
date: $(this)
|
||||
.find('div:nth-child(2) span')
|
||||
.text(),
|
||||
};
|
||||
return info;
|
||||
})
|
||||
.get();
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map(async (itemUrl) => {
|
||||
itemUrl = url.resolve(host, itemUrl);
|
||||
list.map(async (info) => {
|
||||
const itemUrl = url.resolve(host, info.link);
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
@@ -26,6 +36,18 @@ module.exports = async (ctx) => {
|
||||
const response = await axios.get(itemUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
if (itemUrl.indexOf('redirect') !== -1) {
|
||||
const single = {
|
||||
title: $('.rich_media_title')
|
||||
.text()
|
||||
.trim(),
|
||||
link: itemUrl,
|
||||
description: $('.rich_media_content').text(),
|
||||
pubDate: new Date(info.date),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
return Promise.resolve(single);
|
||||
}
|
||||
const single = {
|
||||
title: $('.arti_title').text(),
|
||||
link: itemUrl,
|
||||
|
||||
Reference in New Issue
Block a user