Modefy to get all content and change to V2 (#8724)

Co-authored-by: Tony <TonyRL@users.noreply.github.com>
This commit is contained in:
Fatpandac
2022-01-23 03:18:25 +08:00
committed by GitHub
parent f2858083bb
commit 1fbcede90b
7 changed files with 79 additions and 67 deletions

View File

@@ -2799,31 +2799,6 @@ module.exports = {
},
],
},
'cqwu.net': {
_name: '重庆文理学院',
www: [
{
title: '通知',
docs: 'https://docs.rsshub.app/university.html#chong-qing-wen-li-xue-yuan',
source: '/:type',
target: (params) => {
if (params.type === 'channel_7721.html') {
return '/cqwu/news/notify';
}
},
},
{
title: '学术活动',
docs: 'https://docs.rsshub.app/university.html#chong-qing-wen-li-xue-yuan',
source: '/:type',
target: (params) => {
if (params.type === 'channel_7722.html') {
return '/cqwu/news/academiceve';
}
},
},
],
},
'trakt.tv': {
_name: 'Trakt.tv',
'.': [

View File

@@ -720,9 +720,6 @@ router.get('/cqu/youth/:category', lazyloadRouteHandler('./routes/universities/c
router.get('/cqu/sci/:category', lazyloadRouteHandler('./routes/universities/cqu/sci/info'));
router.get('/cqu/net/:category', lazyloadRouteHandler('./routes/universities/cqu/net/info'));
// 重庆文理学院
router.get('/cqwu/news/:type?', lazyloadRouteHandler('./routes/universities/cqwu/news'));
// 南京信息工程大学
router.get('/nuist/bulletin/:category?', lazyloadRouteHandler('./routes/universities/nuist/bulletin'));
router.get('/nuist/jwc/:category?', lazyloadRouteHandler('./routes/universities/nuist/jwc'));

View File

@@ -1,39 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const url = require('url').resolve;
const host = 'http://www.cqwu.edu.cn';
const map = {
notify: '/channel_7721.html',
academiceve: '/channel_7722.html',
};
const titleMap = {
notify: '通知',
academiceve: '学术活动',
};
module.exports = async (ctx) => {
const type = ctx.params.type || 'academiceve';
const link = host + map[type];
const title = '重文理' + titleMap[type] + '公告';
const response = await got.get(link);
const $ = cheerio.load(response.data);
const list = $('ul[class="list-unstyled news-uls"]').find('li');
ctx.state.data = {
title,
link,
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item.find('h4').text(),
description: item.find('p').text(),
pubDate: new Date(item.find('span[class="pull-right nes-date"]').text()).toUTCString(),
link: url(host, item.find('a').attr('href')),
};
})
.get(),
};
};

46
lib/v2/cqwu/index.js Normal file
View File

@@ -0,0 +1,46 @@
const cheerio = require('cheerio');
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const host = 'http://www.cqwu.net';
const map = {
notify: '/channel_7721.html',
academiceve: '/channel_7722.html',
};
const titleMap = {
notify: '通知',
academiceve: '学术活动',
};
module.exports = async (ctx) => {
const type = ctx.params.type ?? 'academiceve';
const link = host + map[type];
const title = '重文理' + titleMap[type] + '公告';
const response = await got.get(link);
const $ = cheerio.load(response.data);
const list = $('ul[class="list-unstyled news-uls"]').find('li');
const items = await Promise.all(
list.map(async (_, item) => {
const pageUrl = host + $(item).find('a').attr('href');
const desc = await ctx.cache.tryGet(pageUrl, async () => {
const page = await got.get(pageUrl);
const $ = cheerio.load(page.data);
return $('.news-info').html();
});
return {
title: $(item).find('a').text(),
link: pageUrl,
description: desc,
pubDate: parseDate($(item).find('span').text()),
};
})
);
ctx.state.data = {
title,
link,
item: items,
};
};

View File

@@ -0,0 +1,3 @@
module.exports = {
'/news/:type?': ['Fatpandac'],
};

27
lib/v2/cqwu/radar.js Normal file
View File

@@ -0,0 +1,27 @@
module.exports = {
'cqwu.net': {
_name: '重庆文理学院',
www: [
{
title: '通知',
docs: 'https://docs.rsshub.app/university.html#chong-qing-wen-li-xue-yuan',
source: '/:type',
target: (params) => {
if (params.type === 'channel_7721.html') {
return '/cqwu/news/notify';
}
},
},
{
title: '学术活动',
docs: 'https://docs.rsshub.app/university.html#chong-qing-wen-li-xue-yuan',
source: '/:type',
target: (params) => {
if (params.type === 'channel_7722.html') {
return '/cqwu/news/academiceve';
}
},
},
],
},
};

3
lib/v2/cqwu/router.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/news/:type?', require('./index'));
};