feat: 南京艺术学院官网,双馨网,设计学院部分信息 (#10664)

* 南京艺术学院研究生院

* Update lib/v2/nua/gra.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/nua/gra.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/nua/gra.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/nua/radar.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/nua/radar.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/nua/gra.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/nua/gra.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update docs/university.md

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update docs/university.md

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* 优化代码

* 优化

* update

* 补充南京艺术学院

* fix

* fix

* fix

* 更新南京艺术学院数据源。

* 更新南京艺术学院数据源。

* fix

* fix

* update

* fix doc

* fix

* Update lib/v2/nua/radar.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* fix: yarn.lock permission

* style: auto format

* fix double fetch same page

* Update dc.js

* Revert "Merge branch 'master' of https://github.com/evnydd0sf/RSS-Hub"

This reverts commit dd56f9469b5b2462d482c202ae798b3f159f243e, reversing
changes made to d900050eb8271d0f566070eb58c2c9d87ccd6e53.

* fix

* Revert "fix"

This reverts commit 820ff88120d4fb4fc2bdcd8ee52229d1bfb83c17.

* Revert "Revert "Merge branch 'master' of https://github.com/evnydd0sf/RSS-Hub""

This reverts commit ce67e0b53c231a8a8527b7407211aff1ab7e50d4.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
evnydd0sf 2022-09-01 00:35:42 +08:00 committed by GitHub
parent 9e1796944f
commit 8495a355f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 236 additions and 46 deletions

View File

@ -2059,11 +2059,49 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
## 南京艺术学院
### 官网信息
<Route author="evnydd0sf" example="/nua/index/346" path="/nua/index/:type" :paramsDesc="['新闻模块,见下表']" radar="1">
| 新闻模块 | 参数 |
| ---- | --- |
| 公告 | 346 |
| 南艺要闻 | 332 |
</Route>
### 双馨网
<Route author="evnydd0sf" example="/nua/sxw/230" path="/nua/sxw/:type" :paramsDesc="['新闻模块,见下表']" radar="1">
| 新闻模块 | 参数 |
| ---- | --- |
| 校园电视 | 230 |
| 院部动态 | 232 |
| 动感校园 | 233 |
| 招就指南 | 234 |
| 南艺院报 | 236 |
</Route>
### 设计学院
<Route author="evnydd0sf" example="/nua/dc/346" path="/nua/dc/:type" :paramsDesc="['新闻模块,见下表']" radar="1">
| 新闻模块 | 参数 |
| ---------- | ------- |
| 学院新闻 NEWS | news |
| 教学 TEACH | teach |
| 项目 PROJECT | project |
| 党团 PARTY | party |
</Route>
### 研究生处
<Route author="evnydd0sf" example="/nua/gra/1959" path="/nua/gra/:type" :paramsDesc="['种类名,见下表']" radar="1">
<Route author="evnydd0sf" example="/nua/gra/1959" path="/nua/gra/:type" :paramsDesc="['新闻模块,见下表']" radar="1">
| 种类名 | 参数 |
| 新闻模块 | 参数 |
| ----- | ---- |
| 招生工作 | 1959 |
| 培养工作 | 1962 |

53
lib/v2/nua/dc.js Normal file
View File

@ -0,0 +1,53 @@
// const got = require('@/utils/got');
// const cheerio = require('cheerio');
const util = require('./utils');
module.exports = async (ctx) => {
const type = ctx.params.type;
const baseUrl = 'https://dc.nua.edu.cn';
let listName;
let listDate;
let artiContent;
let webPageName;
switch (type) {
case 'news':
listName = 'li.pre35.left li.news_list';
listDate = '.date';
artiContent = '.article';
webPageName = 'li.pre35.left .big_title';
break;
case 'teach':
listName = 'li.pre65.right li.effects';
listDate = '.date';
artiContent = '.article';
webPageName = 'li.pre65.right .big_title';
break;
case 'project':
listName = 'ul.center div.center_list_img';
listDate = '.date';
artiContent = '.article';
webPageName = 'ul.center .big_title';
break;
case 'party':
listName = 'div.pre35.right li.party_list';
listDate = '.date';
artiContent = '.article';
webPageName = 'div.pre35.right .big_title';
break;
default:
throw Error(`暂不支持对${type}的订阅`);
}
const items = await util.ProcessList(baseUrl, baseUrl, listName, listDate, webPageName);
const results = await util.ProcessFeed(items[0], artiContent, ctx.cache);
ctx.state.data = {
title: 'NUA-设计学院-' + items[1],
link: baseUrl,
description: '南京艺术学院 设计学院 ' + items[1],
item: results,
};
};

View File

@ -1,56 +1,21 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
const util = require('./utils');
const baseUrl = 'https://grad.nua.edu.cn';
module.exports = async (ctx) => {
const type = ctx.params.type;
const newsUrl = `${baseUrl}/${type}/list.htm`;
const listName = 'li.list_item';
const artiContent = '.read';
const listDate = '.Article_PublishDate';
const webPageName = '.col_title';
const response = await got(newsUrl, {
https: {
rejectUnauthorized: false,
},
});
const data = response.data;
const $ = cheerio.load(data);
const pagename = $('.col_title').text();
const items = $('li.list_item')
.toArray()
.map((item) => {
item = $(item);
return {
link: baseUrl + item.find('a').attr('href'),
title: item.find('a').attr('title'),
pubDate: timezone(parseDate(item.find('.Article_PublishDate').first().text(), 'YYYY-MM-DD'), +8),
};
});
const results = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const result = await got(item.link, {
https: {
rejectUnauthorized: false,
},
});
const $ = cheerio.load(result.data);
item.author = $('.arti_publisher').text();
item.description = $('.read').html();
return item;
})
)
);
const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName);
const results = await util.ProcessFeed(items[0], artiContent, ctx.cache);
ctx.state.data = {
title: 'NUA-研究生处-' + pagename,
title: 'NUA-研究生处-' + items[1],
link: `${baseUrl}/${type}/list.htm`,
description: '南京艺术学院研究生处' + pagename,
description: '南京艺术学院 研究生处 ' + items[1],
item: results,
};
};

22
lib/v2/nua/index.js Normal file
View File

@ -0,0 +1,22 @@
const util = require('./utils');
module.exports = async (ctx) => {
const type = ctx.params.type;
const baseUrl = 'https://www.nua.edu.cn';
const newsUrl = `${baseUrl}/${type}/list.htm`;
const listName = 'li.news';
const listDate = '.news_meta';
const webPageName = '.col_title';
const artiContent = '.read';
const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName);
const results = await util.ProcessFeed(items[0], artiContent, ctx.cache);
ctx.state.data = {
title: 'NUA-' + items[1],
link: newsUrl,
description: '南京艺术学院 ' + items[1],
item: results,
};
};

View File

@ -1,3 +1,6 @@
module.exports = {
'/dc/:type': ['evnydd0sf'],
'/gra/:type': ['evnydd0sf'],
'/index/:type': ['evnydd0sf'],
'/sxw/:type': ['evnydd0sf'],
};

View File

@ -1,6 +1,30 @@
module.exports = {
'nua.edu.cn': {
_name: '南京艺术学院',
index: [
{
title: '官网信息',
docs: 'https://docs.rsshub.app/university.html#nan-jing-yi-shu-xue-yuan',
source: ['/:type/list.htm'],
target: '/nua/index/:type',
},
],
sxw: [
{
title: '双馨网',
docs: 'https://docs.rsshub.app/university.html#nan-jing-yi-shu-xue-yuan',
source: ['/:type/list.htm'],
target: '/nua/sxw/:type',
},
],
dc: [
{
title: '设计学院',
docs: 'https://docs.rsshub.app/university.html#nan-jing-yi-shu-xue-yuan',
source: ['/:type/list.htm'],
target: '/nua/dc/:type',
},
],
grad: [
{
title: '研究生处',

View File

@ -1,3 +1,6 @@
module.exports = function (router) {
router.get('/dc/:type', require('./dc'));
router.get('/gra/:type', require('./gra'));
router.get('/index/:type', require('./index'));
router.get('/sxw/:type', require('./sxw'));
};

22
lib/v2/nua/sxw.js Normal file
View File

@ -0,0 +1,22 @@
const util = require('./utils');
module.exports = async (ctx) => {
const type = ctx.params.type;
const baseUrl = 'https://sxw.nua.edu.cn';
const newsUrl = `${baseUrl}/${type}/list.htm`;
const listName = 'li.list_item';
const listDate = '.Article_PublishDate';
const webPageName = '.Column_Anchor';
const artiContent = '.read';
const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName);
const results = await util.ProcessFeed(items[0], artiContent, ctx.cache);
ctx.state.data = {
title: 'NUA-双馨网-' + items[1],
link: newsUrl,
description: '南京艺术学院 双馨网 ' + items[1],
item: results,
};
};

60
lib/v2/nua/utils.js Normal file
View File

@ -0,0 +1,60 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
async function ProcessList(newsUrl, baseUrl, listName, listDate, webPageName) {
const result = await got(newsUrl, {
https: {
rejectUnauthorized: false,
},
});
const $ = cheerio.load(result.data);
const pageName = $(webPageName).text();
let artiLink;
const items = $(listName)
.toArray()
.map((item) => {
item = $(item);
if (item.find('a').attr('href').includes('http')) {
artiLink = item.find('a').attr('href');
} else {
artiLink = baseUrl + item.find('a').attr('href');
}
return {
link: artiLink,
title: item.find('a').attr('title'),
pubDate: timezone(parseDate(item.find(listDate).first().text(), 'YYYY-MM-DD'), +8),
};
});
return [items, pageName];
}
const ProcessFeed = async (items, artiContent, cache) =>
await Promise.all(
items.map((item) =>
cache.tryGet(item.link, async () => {
const result = await got(item.link, {
https: {
rejectUnauthorized: false,
},
});
const $ = cheerio.load(result.data);
item.author = $('.arti_publisher').text() + ' ' + $('.arti_views').text();
item.description = $(artiContent).html();
return item;
})
)
);
module.exports = {
ProcessList,
ProcessFeed,
};