mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-13 16:49:31 +08:00
49 lines
1.6 KiB
JavaScript
49 lines
1.6 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
|
|
module.exports = async (ctx) => {
|
|
const category_dict = {
|
|
gyfytdglk: '公用房与土地管理科',
|
|
zfglk: '住房管理科',
|
|
xxzhk: '信息综合科',
|
|
czcjk: '出租出借科',
|
|
gyzcglk: '国有资产管理科',
|
|
};
|
|
|
|
const items = await Promise.all(
|
|
Object.keys(category_dict).map(async (c) => {
|
|
const response = await got({
|
|
method: 'get',
|
|
url: `https://zcc.nju.edu.cn/tzgg/${c}/index.html`,
|
|
});
|
|
|
|
const data = response.data;
|
|
const $ = cheerio.load(data);
|
|
let script = $('ul.list_news_dl').find('script');
|
|
script = script['1'].children[0].data;
|
|
|
|
const start = script.indexOf('[');
|
|
const end = script.lastIndexOf(']');
|
|
const t = JSON.parse(script.substring(start, end + 1));
|
|
|
|
// only read first page
|
|
return Promise.resolve(
|
|
t[0].infolist.map((item) => ({
|
|
title: item.title,
|
|
description: item.summary,
|
|
link: item.url,
|
|
author: item.username,
|
|
pubDate: new Date(item.releasetime).toUTCString(),
|
|
category: category_dict[c],
|
|
}))
|
|
);
|
|
})
|
|
);
|
|
|
|
ctx.state.data = {
|
|
title: '资产管理处-通知公告',
|
|
link: 'https://zcc.nju.edu.cn/tzgg/index.html',
|
|
item: [...items[0], ...items[1], ...items[2], ...items[3], ...items[4]],
|
|
};
|
|
};
|