mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix: 洛阳理工学院 RSS (#4027)
This commit is contained in:
+8
-8
@@ -530,21 +530,21 @@ category 列表:
|
||||
|
||||
### 新闻中心
|
||||
|
||||
<Route author="AngUOI" example="/lit/xwzx/ggtz" path="/universities/lit/xwzx/:name?" :paramsDesc="['默认为 `ggtz`']">
|
||||
<Route author="AngUOI" example="/lit/xwzx" path="/universities/lit/xwzx/:name?" :paramsDesc="['默认为 `all`']">
|
||||
|
||||
| 公告通知 | 新闻快讯 | 学术信息 | 媒体新闻 |
|
||||
| -------- | -------- | -------- | -------- |
|
||||
| ggtz | xwkx | xsxx | mtxw |
|
||||
| 全部 | 公告通知 | 新闻快讯 | 学术信息 | 媒体新闻 |
|
||||
| ---- | -------- | -------- | -------- | -------- |
|
||||
| all | ggtz | xwkx | xsxx | mtxw |
|
||||
|
||||
</Route>
|
||||
|
||||
### 团委
|
||||
|
||||
<Route author="AngUOI" example="/lit/tw/tntz" path="/universities/lit/tw/:name?" :paramsDesc="['默认为 `tntz`']">
|
||||
<Route author="AngUOI" example="/lit/tw" path="/universities/lit/tw/:name?" :paramsDesc="['默认为 `all`']">
|
||||
|
||||
| 团内通知 | 青年快讯 | 理论学习 |
|
||||
| -------- | -------- | -------- |
|
||||
| tntz | qnkx | llxx |
|
||||
| 全部 | 团内通知 | 青年快讯 |
|
||||
| ---- | -------- | -------- |
|
||||
| all | tntz | qnkx |
|
||||
|
||||
</Route>
|
||||
|
||||
|
||||
@@ -1,55 +1,49 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
|
||||
const baseUrl = 'http://www.lit.edu.cn/jwc/';
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: baseUrl,
|
||||
});
|
||||
const response = await got.get(baseUrl);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const items = [];
|
||||
const list = $('article.post_box').get();
|
||||
|
||||
// 获取头条文章
|
||||
$('article.ulist').each(function() {
|
||||
const list = $(this);
|
||||
items.push({
|
||||
title: `【头条】 ` + list.find('a').text(),
|
||||
description: list.find('a').text(),
|
||||
pubDate: list
|
||||
.find('span')
|
||||
.eq(-1)
|
||||
.text(),
|
||||
link: baseUrl + list.find('a').attr('href'),
|
||||
});
|
||||
});
|
||||
const out = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
item = $(item);
|
||||
const link = url.resolve(baseUrl, item.find('a').attr('href'));
|
||||
const single = {
|
||||
title: item.find('a').attr('title'),
|
||||
link: link,
|
||||
};
|
||||
|
||||
// 获取其它文章
|
||||
$('article.post_box').each(function() {
|
||||
const list = $(this);
|
||||
const ddate = list
|
||||
.find('.c-top')
|
||||
.children('div')
|
||||
.text()
|
||||
.trim();
|
||||
items.push({
|
||||
title: list.find('a').attr('title'),
|
||||
description: list.children('.c-con').text(),
|
||||
pubDate: ddate.substring(0, 4) + `-` + ddate.substring(4),
|
||||
link: baseUrl + list.find('a').attr('href'),
|
||||
});
|
||||
});
|
||||
const other = await ctx.cache.tryGet(link, async () => {
|
||||
const result = await got.get(link);
|
||||
const $ = cheerio.load(result.data);
|
||||
|
||||
$('img[src="/system/resource/images/fileTypeImages/icon_xls.gif"]').remove();
|
||||
$('img[src="/system/resource/images/fileTypeImages/icon_doc.gif"]').remove();
|
||||
$('img[src="/system/resource/images/fileTypeImages/icon_ppt.gif"]').remove();
|
||||
|
||||
const description = $('article.entry-content').html();
|
||||
const pubDate = $('time').text();
|
||||
const author = $('aside > span:nth-child(1)').text();
|
||||
return {
|
||||
description,
|
||||
pubDate,
|
||||
author,
|
||||
};
|
||||
});
|
||||
|
||||
return Promise.resolve(Object.assign({}, single, other));
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `洛理教务在线`,
|
||||
title: `教务处 - 洛阳理工学院`,
|
||||
link: baseUrl,
|
||||
description: `洛阳理工教务在线RSS,规范管理 用心服务 欢迎您访问!`,
|
||||
item: items.map((item) => ({
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
pubDate: item.pubDate,
|
||||
link: item.link,
|
||||
})),
|
||||
description: `洛阳理工教务在线 RSS`,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -3,67 +3,56 @@ const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
|
||||
const baseUrl = 'http://www.lit.edu.cn/tw/';
|
||||
|
||||
const nameProps = {
|
||||
tntz: '团内通知',
|
||||
qnkx: '青年快讯',
|
||||
llxx: '理论学习',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const name = ctx.params.name || 'tntz';
|
||||
const u = url.resolve(baseUrl, `${name}.htm`);
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: u,
|
||||
});
|
||||
|
||||
const name = ctx.params.name || 'all';
|
||||
const urla = name === 'all' ? baseUrl : url.resolve(baseUrl, `${name}.htm`);
|
||||
const response = await got.get(urla);
|
||||
const $ = cheerio.load(response.data);
|
||||
const list =
|
||||
name === 'all'
|
||||
? $('.con_wap')
|
||||
.find('li')
|
||||
.get()
|
||||
: $('ul.caselist li').get();
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
item = $(item);
|
||||
const link = url.resolve(baseUrl, item.find('a').attr('href'));
|
||||
const pubDate = name === 'all' ? item.find('span').text() : item.children('.time').text();
|
||||
|
||||
const other = await ctx.cache.tryGet(link, async () => {
|
||||
const result = await got.get(link);
|
||||
const $ = cheerio.load(result.data);
|
||||
$('img[src="/system/resource/images/fileTypeImages/icon_xls.gif"]').remove();
|
||||
$('img[src="/system/resource/images/fileTypeImages/icon_doc.gif"]').remove();
|
||||
$('img[src="/system/resource/images/fileTypeImages/icon_ppt.gif"]').remove();
|
||||
const description = $('#textarea').html();
|
||||
const title = $('article > section > form > h2').text();
|
||||
return {
|
||||
description,
|
||||
title,
|
||||
};
|
||||
});
|
||||
|
||||
const single = {
|
||||
link: link,
|
||||
pubDate,
|
||||
};
|
||||
|
||||
return Promise.resolve(Object.assign({}, single, other));
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${nameProps[name]} - 洛理团委`,
|
||||
link: u,
|
||||
description: `洛阳理工学院团委 - ${nameProps[name]}`,
|
||||
title: name === 'all' ? `团委 - 洛阳理工学院` : `${nameProps[name]} - 洛理团委`,
|
||||
link: urla,
|
||||
description: `洛阳理工学院团委 RSS`,
|
||||
item: out,
|
||||
};
|
||||
|
||||
if (name === 'llxx') {
|
||||
ctx.state.data.item = $('li.newslist')
|
||||
.map((index, item) => ({
|
||||
title: $(item)
|
||||
.find('a.type_one')
|
||||
.text(),
|
||||
description: $(item)
|
||||
.find('li.desc')
|
||||
.text()
|
||||
.trim(),
|
||||
pubDate: $(item)
|
||||
.find('small')
|
||||
.first()
|
||||
.text()
|
||||
.replace(/\//g, '-'),
|
||||
link:
|
||||
baseUrl +
|
||||
$(item)
|
||||
.find('a.type_one')
|
||||
.attr('href'),
|
||||
}))
|
||||
.get();
|
||||
} else {
|
||||
ctx.state.data.item = $('ul.caselist li')
|
||||
.map((index, item) => ({
|
||||
title: $(item)
|
||||
.find('a')
|
||||
.text(),
|
||||
description: '',
|
||||
pubDate: $(item)
|
||||
.find('span.time')
|
||||
.text(),
|
||||
link:
|
||||
baseUrl +
|
||||
$(item)
|
||||
.find('a')
|
||||
.attr('href'),
|
||||
}))
|
||||
.get();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4,7 +4,6 @@ const url = require('url');
|
||||
|
||||
const host = 'http://www.lit.edu.cn/';
|
||||
const baseUrl = 'http://www.lit.edu.cn/xwzx/';
|
||||
|
||||
const nameProps = {
|
||||
ggtz: '公告通知',
|
||||
xwkx: '新闻快讯',
|
||||
@@ -13,39 +12,59 @@ const nameProps = {
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const name = ctx.params.name || 'ggtz';
|
||||
const u = url.resolve(baseUrl, `${name}.htm`);
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: u,
|
||||
});
|
||||
const name = ctx.params.name || 'all';
|
||||
const urla = name === 'all' ? host : url.resolve(baseUrl, `${name}.htm`);
|
||||
const response = await got.get(urla);
|
||||
const $ = cheerio.load(response.data);
|
||||
$('.xxlibottom').remove();
|
||||
const list = name === 'all' ? $('.xxlcleft ul li').get() : $('li.list_item').get();
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
item = $(item);
|
||||
const link = url.resolve(host, item.find('a').attr('href'));
|
||||
const single = {
|
||||
title: item.find('a').attr('title'),
|
||||
link: link,
|
||||
};
|
||||
|
||||
const other = await ctx.cache.tryGet(link, async () => {
|
||||
const result = await got.get(link);
|
||||
const $ = cheerio.load(result.data);
|
||||
|
||||
$('img[src="/system/resource/images/fileTypeImages/icon_xls.gif"]').remove();
|
||||
$('img[src="/system/resource/images/fileTypeImages/icon_doc.gif"]').remove();
|
||||
$('img[src="/system/resource/images/fileTypeImages/icon_ppt.gif"]').remove();
|
||||
const delp = $('.nr_text').find('p');
|
||||
delp.eq(-1).remove();
|
||||
delp.eq(-2).remove();
|
||||
|
||||
const description = $('.nr_text').html();
|
||||
|
||||
const time = $('h6').text();
|
||||
let pubDate = time.match(/\d{4}-\d{1,2}-\d{1,2}/g);
|
||||
if (pubDate === null) {
|
||||
pubDate = time
|
||||
.match(/\d{4}年\d{1,2}月\d{1,2}日 \d{1,2}:\d{1,2}/g)
|
||||
.toString()
|
||||
.replace('年', '-')
|
||||
.replace('月', '-')
|
||||
.replace('日', '');
|
||||
}
|
||||
return {
|
||||
description,
|
||||
pubDate,
|
||||
};
|
||||
});
|
||||
|
||||
return Promise.resolve(Object.assign({}, single, other));
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${nameProps[name]} - 洛理新闻中心`,
|
||||
link: u,
|
||||
description: `洛阳理工学院新闻中心 - ${nameProps[name]}`,
|
||||
item: $('li.list_item')
|
||||
.map((index, item) => ({
|
||||
title: $(item)
|
||||
.find('a')
|
||||
.attr('title'),
|
||||
description: '',
|
||||
author: $(item)
|
||||
.find('.Article_PublishDate')
|
||||
.text()
|
||||
.replace(/\d{4}年\d{2}月\d{2}日/g, '')
|
||||
.replace(',', '')
|
||||
.trim(),
|
||||
pubDate: $(item)
|
||||
.find('.Article_PublishDate')
|
||||
.text()
|
||||
.match(/[A-Za-z0-9_]+/g)
|
||||
.join('-'),
|
||||
link: $(item)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace('../', host),
|
||||
}))
|
||||
.get(),
|
||||
title: name === 'all' ? `新闻中心 - 洛阳理工学院` : `${nameProps[name]} - 洛理新闻中心`,
|
||||
link: urla,
|
||||
description: `洛阳理工学院新闻中心 RSS`,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user