mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-07 21:47:57 +08:00
* fix(route): 南京理工大学 * refactor: migrate to v2 * refactor: migrate to v2 * Update yarn.lock * fix: remove standalone puppeteer extra * fix(route): minor misc changes * fix(route): sort routes in alphabetical order * fix(route): update utils.js
41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
const cheerio = require('cheerio');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
const timezone = require('@/utils/timezone');
|
|
const { getContent } = require('./utils');
|
|
|
|
const map = new Map([
|
|
['gstz', { title: '南京理工大学电光学院研学网 -- 公示通知', id: '/6509' }],
|
|
['xswh', { title: '南京理工大学电光学院研学网 -- 学术文化', id: '/6511' }],
|
|
['jyzd', { title: '南京理工大学电光学院研学网 -- 就业指导', id: '/6510' }],
|
|
]);
|
|
|
|
const host = 'https://dgxg.njust.edu.cn';
|
|
|
|
module.exports = async (ctx) => {
|
|
const type = ctx.params.type ?? 'gstz';
|
|
const info = map.get(type);
|
|
if (!info) {
|
|
throw 'invalid type';
|
|
}
|
|
const id = info.id;
|
|
const siteUrl = host + id + '/list.htm';
|
|
|
|
const html = await getContent(siteUrl, true);
|
|
const $ = cheerio.load(html);
|
|
const list = $('ul.wp_article_list').find('li');
|
|
|
|
ctx.state.data = {
|
|
title: info.title,
|
|
link: siteUrl,
|
|
item:
|
|
list &&
|
|
list
|
|
.map((index, item) => ({
|
|
title: $(item).find('a').attr('title').trim(),
|
|
pubDate: timezone(parseDate($(item).find('span.Article_PublishDate').text(), 'YYYY-MM-DD'), +8),
|
|
link: $(item).find('a').attr('href'),
|
|
}))
|
|
.get(),
|
|
};
|
|
};
|