mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-04 19:59:54 +08:00
feat: 增加设计学院研创、后浪模块;支持获取微信文章内容;修复重复条目bug (#10994)
* 南京艺术学院研究生院 * 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 commitdd56f9469b, reversing changes made tod900050eb8. * fix * Revert "fix" This reverts commit820ff88120. * Revert "Revert "Merge branch 'master' of https://github.com/evnydd0sf/RSS-Hub"" This reverts commitce67e0b53c. * 增加微信公众号解析引导。 * 修正url * 适配微信公众号内容。 * 适配站内文章、微信公号号文章和未知文章引导。 * Update wechat-mp.js * fix fetch wechat bug * 增加设计学院研创、后浪模块 * bugfix * Revert "Merge branch 'DIYgod:master' into master" This reverts commit102cb48db6, reversing changes made toccac4be518. * Update university.md * Revert "Revert "Merge branch 'DIYgod:master' into master"" This reverts commitc8841910b8. * fix fetch listname * fix: switch default case Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@@ -2116,14 +2116,16 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
|
|||||||
|
|
||||||
### 设计学院
|
### 设计学院
|
||||||
|
|
||||||
<Route author="evnydd0sf" example="/nua/dc/346" path="/nua/dc/:type" :paramsDesc="['新闻模块,见下表']" radar="1">
|
<Route author="evnydd0sf" example="/nua/dc/news" path="/nua/dc/:type" :paramsDesc="['新闻模块,见下表']" radar="1">
|
||||||
|
|
||||||
| 新闻模块 | 参数 |
|
| 新闻模块 | 参数 |
|
||||||
| ---------- | ------- |
|
| ---------------------- | ---------- |
|
||||||
| 学院新闻 NEWS | news |
|
| 学院新闻 NEWS | news |
|
||||||
| 教学 TEACH | teach |
|
| 展览 EXHIBITION | exhibition |
|
||||||
| 项目 PROJECT | project |
|
| 研创 RESEARCH & CREATION | rc |
|
||||||
| 党团 PARTY | party |
|
| 项目 PROJECT | project |
|
||||||
|
| 党团 PARTY | party |
|
||||||
|
| 后浪 YOUTH | youth |
|
||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
@@ -2131,12 +2133,11 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
|
|||||||
|
|
||||||
<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 |
|
| 招生工作 | 1959 |
|
||||||
| 培养工作 | 1962 |
|
| 培养工作 | 1962 |
|
||||||
| 学位工作 | 1958 |
|
| 学位工作 | 1958 |
|
||||||
| 思政与管理 | 1960 |
|
|
||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
* lib/v2/gzh360
|
* lib/v2/gzh360
|
||||||
* lib/v2/pku/nsd/gd
|
* lib/v2/pku/nsd/gd
|
||||||
* lib/v2/sdu/cs
|
* lib/v2/sdu/cs
|
||||||
|
* lib/v2/nua/utils
|
||||||
*
|
*
|
||||||
* If your new route is not in the above folders, please add it to the list.
|
* If your new route is not in the above folders, please add it to the list.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// const got = require('@/utils/got');
|
|
||||||
// const cheerio = require('cheerio');
|
|
||||||
const util = require('./utils');
|
const util = require('./utils');
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
@@ -19,7 +17,7 @@ module.exports = async (ctx) => {
|
|||||||
artiContent = '.article';
|
artiContent = '.article';
|
||||||
webPageName = 'li.pre35.left .big_title';
|
webPageName = 'li.pre35.left .big_title';
|
||||||
break;
|
break;
|
||||||
case 'teach':
|
case 'exhibition':
|
||||||
listName = 'li.pre65.right li.effects';
|
listName = 'li.pre65.right li.effects';
|
||||||
listDate = '.date';
|
listDate = '.date';
|
||||||
artiContent = '.article';
|
artiContent = '.article';
|
||||||
@@ -31,18 +29,30 @@ module.exports = async (ctx) => {
|
|||||||
artiContent = '.article';
|
artiContent = '.article';
|
||||||
webPageName = 'ul.center .big_title';
|
webPageName = 'ul.center .big_title';
|
||||||
break;
|
break;
|
||||||
|
case 'rc':
|
||||||
|
listName = 'div.pre65.left p.small_content_2';
|
||||||
|
listDate = '.date';
|
||||||
|
artiContent = '.article';
|
||||||
|
webPageName = 'div.pre65.left.is-inview .big_title';
|
||||||
|
break;
|
||||||
case 'party':
|
case 'party':
|
||||||
listName = 'div.pre35.right li.party_list';
|
listName = 'div.pre35.right li.party_list';
|
||||||
listDate = '.date';
|
listDate = '.date';
|
||||||
artiContent = '.article';
|
artiContent = '.article';
|
||||||
webPageName = 'div.pre35.right .big_title';
|
webPageName = 'div.pre35.right .big_title';
|
||||||
break;
|
break;
|
||||||
|
case 'youth':
|
||||||
|
listName = 'ul.works_list p.small_content_2.viewpoint';
|
||||||
|
listDate = '.date';
|
||||||
|
artiContent = '.article';
|
||||||
|
webPageName = 'ul.screen_4 .big_title';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw Error(`暂不支持对${type}的订阅`);
|
throw Error(`暂不支持对${type}的订阅`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const items = await util.ProcessList(baseUrl, baseUrl, listName, listDate, webPageName);
|
const items = await util.ProcessList(baseUrl, baseUrl, listName, listDate, webPageName);
|
||||||
const results = await util.ProcessFeed(items[0], artiContent, ctx.cache);
|
const results = await util.ProcessFeed(items[0], artiContent, ctx);
|
||||||
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
title: 'NUA-设计学院-' + items[1],
|
title: 'NUA-设计学院-' + items[1],
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ module.exports = async (ctx) => {
|
|||||||
const webPageName = '.col_title';
|
const webPageName = '.col_title';
|
||||||
|
|
||||||
const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName);
|
const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName);
|
||||||
const results = await util.ProcessFeed(items[0], artiContent, ctx.cache);
|
const results = await util.ProcessFeed(items[0], artiContent, ctx);
|
||||||
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
title: 'NUA-研究生处-' + items[1],
|
title: 'NUA-研究生处-' + items[1],
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ module.exports = async (ctx) => {
|
|||||||
|
|
||||||
const artiContent = '.read';
|
const artiContent = '.read';
|
||||||
const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName);
|
const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName);
|
||||||
const results = await util.ProcessFeed(items[0], artiContent, ctx.cache);
|
const results = await util.ProcessFeed(items[0], artiContent, ctx);
|
||||||
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
title: 'NUA-' + items[1],
|
title: 'NUA-' + items[1],
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ module.exports = async (ctx) => {
|
|||||||
|
|
||||||
const artiContent = '.read';
|
const artiContent = '.read';
|
||||||
const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName);
|
const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName);
|
||||||
const results = await util.ProcessFeed(items[0], artiContent, ctx.cache);
|
const results = await util.ProcessFeed(items[0], artiContent, ctx);
|
||||||
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
title: 'NUA-双馨网-' + items[1],
|
title: 'NUA-双馨网-' + items[1],
|
||||||
|
|||||||
@@ -2,6 +2,25 @@ const got = require('@/utils/got');
|
|||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
const { parseDate } = require('@/utils/parse-date');
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
const timezone = require('@/utils/timezone');
|
const timezone = require('@/utils/timezone');
|
||||||
|
const { fetchArticle } = require('@/utils/wechat-mp');
|
||||||
|
|
||||||
|
const pageType = (href) => {
|
||||||
|
if (!href.startsWith('http')) {
|
||||||
|
return 'in-nua';
|
||||||
|
}
|
||||||
|
const url = new URL(href);
|
||||||
|
if (url.hostname === 'mp.weixin.qq.com') {
|
||||||
|
return 'wechat-mp';
|
||||||
|
} else if (url.hostname === 'www.nua.edu.cn') {
|
||||||
|
return 'nua';
|
||||||
|
} else {
|
||||||
|
return 'unknown';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function arti_link(text, href) {
|
||||||
|
return `<a href="${href}">${text}</a>`;
|
||||||
|
}
|
||||||
|
|
||||||
async function ProcessList(newsUrl, baseUrl, listName, listDate, webPageName) {
|
async function ProcessList(newsUrl, baseUrl, listName, listDate, webPageName) {
|
||||||
const result = await got(newsUrl, {
|
const result = await got(newsUrl, {
|
||||||
@@ -13,43 +32,44 @@ async function ProcessList(newsUrl, baseUrl, listName, listDate, webPageName) {
|
|||||||
|
|
||||||
const pageName = $(webPageName).text();
|
const pageName = $(webPageName).text();
|
||||||
|
|
||||||
let artiLink;
|
|
||||||
|
|
||||||
const items = $(listName)
|
const items = $(listName)
|
||||||
.toArray()
|
.toArray()
|
||||||
.map((item) => {
|
.map((item) => {
|
||||||
item = $(item);
|
item = $(item);
|
||||||
if (item.find('a').attr('href').includes('http')) {
|
const href = $(item).find('a').attr('href');
|
||||||
artiLink = item.find('a').attr('href');
|
const type = pageType(href);
|
||||||
} else {
|
|
||||||
artiLink = baseUrl + item.find('a').attr('href');
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
link: artiLink,
|
link: type === 'in-nua' ? baseUrl + href : href,
|
||||||
title: item.find('a').attr('title'),
|
title: item.find('a').attr('title'),
|
||||||
pubDate: timezone(parseDate(item.find(listDate).first().text(), 'YYYY-MM-DD'), +8),
|
pubDate: timezone(parseDate(item.find(listDate).first().text(), 'YYYY-MM-DD'), +8),
|
||||||
|
type,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return [items, pageName];
|
return [items, pageName];
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProcessFeed = async (items, artiContent, cache) =>
|
const ProcessFeed = async (items, artiContent, ctx) =>
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
items.map((item) =>
|
items.map((item) =>
|
||||||
cache.tryGet(item.link, async () => {
|
ctx.cache.tryGet(item.link, async () => {
|
||||||
const result = await got(item.link, {
|
switch (item.type) {
|
||||||
https: {
|
case 'in-nua' || 'nua':
|
||||||
rejectUnauthorized: false,
|
// eslint-disable-next-line no-case-declarations
|
||||||
},
|
const result = await got(item.link, { https: { rejectUnauthorized: false } });
|
||||||
});
|
// eslint-disable-next-line no-case-declarations
|
||||||
const $ = cheerio.load(result.data);
|
const $ = cheerio.load(result.data);
|
||||||
|
item.author = $('.arti_publisher').text() + ' ' + $('.arti_views').text();
|
||||||
item.author = $('.arti_publisher').text() + ' ' + $('.arti_views').text();
|
item.description = $(artiContent).html();
|
||||||
item.description = $(artiContent).html();
|
return item;
|
||||||
|
case 'wechat-mp':
|
||||||
return item;
|
return fetchArticle(ctx, item.link);
|
||||||
|
case 'unknown':
|
||||||
|
default:
|
||||||
|
item.description = `暂不支持解析该内容,请点击 ${arti_link('原文', item.link)}`;
|
||||||
|
return item;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user