mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-04 19:59:54 +08:00
* feat(sduwh): add extractors.
* feat(route): add route for 山东大学(威海)新闻网
* docs: for route sduwh/news
* docs: for route sduwh/news
(cherry picked from commit 831830167a)
* feat(radar): for route 山东大学(威海)新闻网
* refactor: change `got.get` to `got`.
* refactor: prefer `parseDate()` to `new Date()`
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
* fix: incomplete URL substring sanitization.
Make CodeQL happy.
* fix(radar): fix target field.
* fix: change route /sduwh to /sdu/wh
* fix: remove superfluous slash character in url.
* feat: look for exact date first.
* feat: extract exact date from news extractor.
* feat: extract exact date from view extractor.
* feat: extractor for www.sdrj.sdu.edu.cn
* refactor: semantic separation of sduwh with sdu
* feat(radar): more accurate name
* docs: update documentation
* refactor: migrate to v2
* refactor: fix deprecated url.resolve
* fix: update docs url
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
* fix: sdu not working routes
* fix: accurate `ctx.state.data.url`
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
* fix: better error handling for extractors.
* fix: timezone
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
* fix: better error handling.
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
58 lines
2.0 KiB
JavaScript
58 lines
2.0 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
const { finishArticleItem } = require('@/utils/wechat-mp');
|
|
|
|
const host = 'https://www.cs.sdu.edu.cn/';
|
|
const typelist = ['学院公告', '学术报告', '科技简讯'];
|
|
const urlList = ['xygg.htm', 'xsbg.htm', 'kjjx.htm'];
|
|
|
|
module.exports = async (ctx) => {
|
|
const type = ctx.params.type ? parseInt(ctx.params.type) : 0;
|
|
const link = new URL(urlList[type], host).href;
|
|
|
|
const response = await got(link);
|
|
|
|
const $ = cheerio.load(response.data);
|
|
|
|
let item = $('.dqlb ul li')
|
|
.map((_, e) => {
|
|
e = $(e);
|
|
const a = e.find('a');
|
|
return {
|
|
title: a.text().trim(),
|
|
link: a.attr('href').startsWith('info/') ? host + a.attr('href') : a.attr('href'),
|
|
pubDate: parseDate(e.find('.fr').text().trim(), 'YYYY-MM-DD'),
|
|
};
|
|
})
|
|
.get();
|
|
|
|
item = await Promise.all(
|
|
item.map((item) =>
|
|
ctx.cache.tryGet(item.link, async () => {
|
|
if (new URL(item.link).hostname === 'mp.weixin.qq.com') {
|
|
return finishArticleItem(ctx, item);
|
|
} else if (new URL(item.link).hostname !== 'www.cs.sdu.edu.cn') {
|
|
return item;
|
|
}
|
|
const response = await got(item.link);
|
|
const $ = cheerio.load(response.data);
|
|
|
|
item.title = $('.xqnr_tit h2').text().trim();
|
|
item.author = $('.xqnr_tit span').eq(1).text().trim().replace('编辑:', '') || '山东大学计算机科学与技术学院';
|
|
$('.xqnr_tit').remove();
|
|
item.description = $('form[name=_newscontent_fromname]').html();
|
|
|
|
return item;
|
|
})
|
|
)
|
|
);
|
|
|
|
ctx.state.data = {
|
|
title: `山东大学计算机科学与技术学院${typelist[type]}通知`,
|
|
description: $('title').text(),
|
|
link,
|
|
item,
|
|
};
|
|
};
|