Merge branch 'master' of https://github.com/DIYgod/RSSHub
This commit is contained in:
+38
-5
@@ -735,6 +735,11 @@ GitHub 官方也提供了一些 RSS:
|
||||
|
||||
<route name="新片精品" author="imgss" example="/dytt/index" path="/dytt/index"/>
|
||||
|
||||
### 老司机
|
||||
|
||||
<route name="首页" author="xyqfer" example="/laosiji/feed" path="/laosiji/feed"/>
|
||||
<route name="24小时热门" author="xyqfer" example="/laosiji/hot" path="/laosiji/hot"/>
|
||||
|
||||
## 图片
|
||||
|
||||
### 妹子图
|
||||
@@ -945,20 +950,22 @@ GitHub 官方也提供了一些 RSS:
|
||||
|
||||
### 西南科技大学
|
||||
|
||||
<route name="教务处通知" author="lengthmin" example="/swust/jwc/1" path="/universities/swust/jwc/:type" :paramsDesc="['分区 type, 详见下方表格']">
|
||||
<route name="教务处新闻" author="lengthmin" example="/swust/jwc/news" path="/universities/swust/jwc/news"/>
|
||||
<route name="教务处通知" author="lengthmin" example="/swust/jwc/notice/1" path="/universities/swust/jwc/notice/:type?" :paramsDesc="['分区 type,缺省为 1, 详见下方表格']">
|
||||
|
||||
| 通知公告 | 学校新闻 |
|
||||
| -------- | -------- |
|
||||
| 1 | 2 |
|
||||
| 创新创业教育 | 学生学业 | 建设与改革 | 教学质量保障 | 教学运行 | 教师教学 |
|
||||
| ------------ | -------- | ---------- | ------------ | -------- | -------- |
|
||||
| 1 | 2 | 3 | 4 | 5 | 6 |
|
||||
|
||||
</route>
|
||||
<route name="计科学院通知" author="lengthmin" example="/swust/cs/1" path="/universities/swust/cs/:type" :paramsDesc="['分区 type, 详见下方表格']">
|
||||
<route name="计科学院通知" author="lengthmin" example="/swust/cs/1" path="/universities/swust/cs/:type?" :paramsDesc="['分区 type, 缺省为 1, 详见下方表格']">
|
||||
|
||||
| 新闻动态 | 学术动态 | 通知公告 | 教研动态 |
|
||||
| -------- | -------- | -------- | -------- |
|
||||
| 1 | 2 | 3 | 4 |
|
||||
|
||||
</route>
|
||||
|
||||
### 北京大学
|
||||
|
||||
<route name="信科公告通知" author="Ir1d" example="/pku/eecs/0" path="/universities/pku/eecs/:type" :paramsDesc="['分区 type, 可在网页 URL 中找到']">
|
||||
@@ -1391,6 +1398,18 @@ Category 列表:
|
||||
|
||||
</route>
|
||||
|
||||
### 多维新闻网
|
||||
|
||||
<route name="要闻" author="HenryQW" example="/dwnews/yaowen/global" path="/dwnews/yaowen/:region?" :paramsDesc="['要闻地区,默认`全部`,可选地区如下']">
|
||||
|
||||
| 全部 | 国际 | 中国 | 香港 | 台湾 |
|
||||
| ------ | ------ | ----- | -------- | ------ |
|
||||
| yaowen | global | china | hongkong | taiwan |
|
||||
|
||||
</route>
|
||||
|
||||
<route name="新闻排行榜" author="HenryQW" example="/dwnews/rank/photo/7" path="/dwnews/rank/:type/:range" :paramsDesc="['榜单类型,`news`为普通新闻,`photo`为图集新闻','榜单范围(天),`1` 或 `7`']"/>
|
||||
|
||||
## 预报预警
|
||||
|
||||
### 停水通知
|
||||
@@ -1851,3 +1870,17 @@ IATA 国际航空运输协会机场代码, 参见[维基百科 国际航空运
|
||||
### 观止(每日一文)
|
||||
|
||||
<route name="观止" author="Andiedie" example="/guanzhi" path="/guanzhi"/>
|
||||
|
||||
### 知晓程序
|
||||
|
||||
<route name="文章" author="HenryQW" example="/miniapp/article/cloud" path="/miniapp/article/:category" :paramsDesc="['分类名称']">
|
||||
|
||||
| 全部 | 小程序资讯 | 知晓云 | 小程序推荐 | 榜单 | 晓组织 | 新能力 | 小程序问答 |
|
||||
| ---- | ---------- | ------ | -------------- | ---- | ------ | ---------- | ---------- |
|
||||
| all | news | cloud | recommendation | rank | group | capability | qa |
|
||||
|
||||
</route>
|
||||
|
||||
### 后续
|
||||
|
||||
<route name="后续" author="fengkx" example="/houxu/events/38" path="/houxu/:type/:id" :paramsDesc="['类型', 'ID']"/>
|
||||
|
||||
@@ -505,8 +505,9 @@ router.get('/shmtu/notes', require('./routes/universities/shmtu/notes'));
|
||||
router.get('/shmtu/jwc/:type', require('./routes/universities/shmtu/jwc'));
|
||||
|
||||
// 西南科技大学
|
||||
router.get('/swust/jwc/:type', require('./routes/universities/swust/jwc'));
|
||||
router.get('/swust/cs/:type', require('./routes/universities/swust/cs'));
|
||||
router.get('/swust/jwc/news', require('./routes/universities/swust/jwc_news'));
|
||||
router.get('/swust/jwc/notice/:type?', require('./routes/universities/swust/jwc_notice'));
|
||||
router.get('/swust/cs/:type?', require('./routes/universities/swust/cs'));
|
||||
|
||||
// 华南师范大学
|
||||
router.get('/scnu/jw', require('./routes/universities/scnu/jw'));
|
||||
@@ -628,4 +629,18 @@ router.get('/pediy/topic/:category?/:type?', require('./routes/pediy/topic'));
|
||||
// 观止(每日一文)
|
||||
router.get('/guanzhi', require('./routes/guanzhi/guanzhi'));
|
||||
|
||||
// 多维新闻网
|
||||
router.get('/dwnews/yaowen/:region?', require('./routes/dwnews/yaowen'));
|
||||
router.get('/dwnews/rank/:type/:range', require('./routes/dwnews/rank'));
|
||||
|
||||
// 知晓程序
|
||||
router.get('/miniapp/article/:category', require('./routes/miniapp/article'));
|
||||
|
||||
// 后续
|
||||
router.get('/houxu/:type/:id', require('./routes/houxu/houxu'));
|
||||
|
||||
// 老司机
|
||||
router.get('/laosiji/hot', require('./routes/laosiji/hot'));
|
||||
router.get('/laosiji/feed', require('./routes/laosiji/feed'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await axios.get('http://www.dwnews.com/html/share/24-7topnews.js');
|
||||
|
||||
const data = JSON.parse(response.data.replace('var rankingData = ', ''));
|
||||
|
||||
let list, title;
|
||||
switch (ctx.params.type) {
|
||||
case 'news':
|
||||
if (ctx.params.range === '1') {
|
||||
list = data.newsRanklist['24H'];
|
||||
title = '新闻 24 小时排行';
|
||||
} else {
|
||||
list = data.newsRanklist['7D'];
|
||||
title = '新闻 7 日排行';
|
||||
}
|
||||
break;
|
||||
case 'photo':
|
||||
if (ctx.params.range === '1') {
|
||||
list = data.photoRanklist['24H'];
|
||||
title = '图集 24 小时排行';
|
||||
} else {
|
||||
list = data.photoRanklist['7D'];
|
||||
title = '图集 7 日排行';
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const out = await Promise.all(
|
||||
list.slice(0, 10).map(async (item) => {
|
||||
const cache = await ctx.cache.get(item.url);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
item.url = 'http://news.dwnews.com/global/news/2018-10-08/60089463.html';
|
||||
const response = await axios.get(item.url.replace('.html', '_all.html'));
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const result = utils.ProcessRank($, item);
|
||||
|
||||
const single = {
|
||||
title: item.title,
|
||||
link: item.url,
|
||||
author: result.author,
|
||||
description: result.description,
|
||||
pubDate: result.pubDate,
|
||||
};
|
||||
ctx.cache.set(item.url, JSON.stringify(single), 2 * 60 * 60);
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `多维新闻网 - ${title}`,
|
||||
description: '多维新闻网—记住世界的轨迹 更需多维的视线,海外华人首选的中文门户新闻网站,及时全面的向全球海外华人更新世界各地时事政治、经济、科技、人文历史、图片、视频等新闻内容,是海外华人必上的新闻门户网站。',
|
||||
link: 'http://www.dwnews.com/',
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,78 @@
|
||||
const ProcessFeed = ($, item) => {
|
||||
let content;
|
||||
if (item.filetype === 'TJ') {
|
||||
const images = $('div#slider_component_4_0 > img');
|
||||
|
||||
$('div.captions > p').each((i, e) => {
|
||||
$(images[i]).insertBefore(e);
|
||||
});
|
||||
|
||||
content = $('div.captions');
|
||||
} else {
|
||||
content = $('div.dia-lead-one');
|
||||
}
|
||||
|
||||
ProcessQuote($, content);
|
||||
ProcessImage($, content);
|
||||
Clean($, content);
|
||||
|
||||
return content.html();
|
||||
};
|
||||
|
||||
const ProcessRank = ($) => {
|
||||
let content, author;
|
||||
|
||||
const pubDate = new Date($('div.time').text());
|
||||
pubDate.setHours(pubDate.getHours() - 8);
|
||||
|
||||
content = $('div.dia-lead-one');
|
||||
|
||||
if (content.length === 0) {
|
||||
content = $('div.container');
|
||||
|
||||
author = $('div.author').text();
|
||||
} else {
|
||||
author = $('div.nw').text();
|
||||
}
|
||||
|
||||
ProcessQuote($, content);
|
||||
ProcessImage($, content);
|
||||
Clean($, content);
|
||||
|
||||
return {
|
||||
description: content.html(),
|
||||
author,
|
||||
pubDate,
|
||||
};
|
||||
};
|
||||
|
||||
const ProcessQuote = ($, content) => {
|
||||
content.find('div.ed-top').each((i, e) => {
|
||||
const quote = $(e).siblings('p');
|
||||
if (quote.length > 0) {
|
||||
$(`<blockquote>${quote.text()}</blockquote>`).insertBefore(e);
|
||||
|
||||
$(quote).remove();
|
||||
$(e).remove();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const ProcessImage = ($, content) => {
|
||||
content.find('a[href="javascript:;"]').each((i, e) => {
|
||||
const img = $(e).find('img');
|
||||
$(img).insertBefore(e);
|
||||
$(e).remove();
|
||||
});
|
||||
};
|
||||
|
||||
const Clean = ($, content) => {
|
||||
content.find('div.clear, div.badoo, div.hu-bqsm, div.sign, div.xyy, div#component_14_0').each((i, e) => {
|
||||
$(e).remove();
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
ProcessFeed,
|
||||
ProcessRank,
|
||||
};
|
||||
@@ -0,0 +1,69 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = 'http://news.dwnews.com';
|
||||
let region,
|
||||
host,
|
||||
title = '要闻';
|
||||
|
||||
if (ctx.params.region) {
|
||||
region = ctx.params.region.toLowerCase();
|
||||
switch (region) {
|
||||
case 'china':
|
||||
title = `中国${title}`;
|
||||
break;
|
||||
case 'global':
|
||||
title = `国际${title}`;
|
||||
break;
|
||||
case 'hongkong':
|
||||
title = `香港${title}`;
|
||||
break;
|
||||
case 'taiwan':
|
||||
title = `台湾${title}`;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
host = `${link}/html/news/${region}/list0.json`;
|
||||
} else {
|
||||
region = 'yaowen';
|
||||
host = `${link}/html/news/yaowen/list0.json`;
|
||||
}
|
||||
|
||||
const list = await axios.get(host);
|
||||
|
||||
const out = await Promise.all(
|
||||
list.data.slice(0, 10).map(async (item) => {
|
||||
const cache = await ctx.cache.get(item.url);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
const response = await axios.get(item.url.replace('.html', '_all.html'));
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const pubDate = new Date(item.showTime);
|
||||
pubDate.setHours(pubDate.getHours() - 8);
|
||||
|
||||
const description = utils.ProcessFeed($, item);
|
||||
|
||||
const single = {
|
||||
title: item.title,
|
||||
link: item.url,
|
||||
author: $('div.nw').text(),
|
||||
description,
|
||||
pubDate: pubDate.toUTCString(),
|
||||
};
|
||||
ctx.cache.set(item.url, JSON.stringify(single), 2 * 60 * 60);
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `多维新闻网 - ${title}`,
|
||||
description: '多维新闻网—记住世界的轨迹 更需多维的视线,海外华人首选的中文门户新闻网站,及时全面的向全球海外华人更新世界各地时事政治、经济、科技、人文历史、图片、视频等新闻内容,是海外华人必上的新闻门户网站。',
|
||||
link: `${region === 'yaowen' ? link : link + '/' + region}`,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { type, id } = ctx.params;
|
||||
const baseUrl = `https://houxu.app/${type}/${id}`;
|
||||
const res = await axios.get(baseUrl);
|
||||
const data = res.data;
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
const list = $('section.threads > div').get();
|
||||
const descriptionSelector = type === 'live' ? '.summary' : '.readable';
|
||||
const out = list.map((item) => {
|
||||
const each = $(item);
|
||||
return {
|
||||
title: each
|
||||
.find('a')
|
||||
.text()
|
||||
.trim(),
|
||||
description: each
|
||||
.find(descriptionSelector)
|
||||
.text()
|
||||
.trim(),
|
||||
link: each.find('a').attr('href'),
|
||||
};
|
||||
});
|
||||
ctx.state.data = {
|
||||
title: $('.large-title').text(),
|
||||
description: $('title')
|
||||
.text()
|
||||
.trim(),
|
||||
link: baseUrl,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
@@ -1,9 +1,9 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
let host = 'http://www.ifanr.com';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let host = 'http://www.ifanr.com';
|
||||
|
||||
if (ctx.params.channel) {
|
||||
let channel = ctx.params.channel.toLowerCase();
|
||||
channel = channel.split('-').join('/');
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
const axios = require('../../utils/axios');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await axios({
|
||||
method: 'post',
|
||||
url: 'http://www.laosiji.com/api/topic/feed/list',
|
||||
});
|
||||
|
||||
const data = response.data.body.sns.list;
|
||||
|
||||
ctx.state.data = {
|
||||
title: '老司机-首页',
|
||||
link: 'http://www.laosiji.com/new_web/index.html',
|
||||
description: '老司机-首页',
|
||||
item: data.map(({ title, resourceid, image, publishtime }) => ({
|
||||
title,
|
||||
link: `http://www.laosiji.com/thread/${resourceid}.html`,
|
||||
description: `<img referrerpolicy="no-referrer" src="${image.url}">`,
|
||||
pubDate: publishtime,
|
||||
})),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
const axios = require('../../utils/axios');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: 'http://www.laosiji.com/thread/hotList',
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
|
||||
ctx.state.data = {
|
||||
title: '老司机-24小时热门',
|
||||
link: 'http://www.laosiji.com/new_web/index.html',
|
||||
description: '老司机-24小时热门',
|
||||
item: data.map(({ title, id, imageInfo, createtime }) => ({
|
||||
title,
|
||||
link: `http://www.laosiji.com/thread/${id}.html`,
|
||||
description: `<img referrerpolicy="no-referrer" src="${imageInfo.url}">`,
|
||||
pubDate: new Date(createtime).toUTCString(),
|
||||
})),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
const axios = require('../../utils/axios');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category.toLowerCase();
|
||||
|
||||
let host = `https://minapp.com/api/v5/trochili/post/?category=${category}&post_type=article&limit=10`;
|
||||
|
||||
if (category === 'all') {
|
||||
host = 'https://minapp.com/api/v5/trochili/post/?post_type=article&limit=10';
|
||||
}
|
||||
|
||||
let title;
|
||||
switch (category) {
|
||||
case 'news':
|
||||
title = '小程序资讯';
|
||||
break;
|
||||
case 'cloud':
|
||||
title = '知晓云';
|
||||
break;
|
||||
case 'recommendation':
|
||||
title = '小程序推荐';
|
||||
break;
|
||||
case 'rank':
|
||||
title = '榜单';
|
||||
break;
|
||||
case 'group':
|
||||
title = '晓组织';
|
||||
break;
|
||||
case 'capability':
|
||||
title = '新能力';
|
||||
break;
|
||||
case 'qa':
|
||||
title = '小程序问答';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const response = await axios.get(host);
|
||||
|
||||
const list = response.data.objects;
|
||||
|
||||
const out = list.map((item) => ({
|
||||
title: item.title,
|
||||
link: `https://minapp.com/article/${item.id}`,
|
||||
author: item.created_by.nickname,
|
||||
description: item.content,
|
||||
pubDate: new Date(item.created_at * 1000),
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `知晓程序${title ? ' - ' + title : ''}`,
|
||||
description: '知晓程序 | 一扫即用的小程序大全',
|
||||
link: `https://minapp.com/article/?page=1&category=${category}`,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
+31
-29
@@ -1,5 +1,5 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const dateHelper = require('../../utils/date');
|
||||
const pediyUtils = require('./utils');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const baseUrl = 'https://bbs.pediy.com/';
|
||||
@@ -56,40 +56,42 @@ module.exports = async (ctx) => {
|
||||
},
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('.thread');
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${title}`,
|
||||
link: baseUrl + path,
|
||||
item: $('.thread')
|
||||
.map((_, elem) => {
|
||||
const subject = $('.subject a', elem).eq(1);
|
||||
const author = $('.username', elem).eq(0);
|
||||
item:
|
||||
list &&
|
||||
list
|
||||
.map((_, elem) => {
|
||||
const subject = $('.subject a', elem).eq(1);
|
||||
const author = $('.username', elem).eq(0);
|
||||
|
||||
let pubDate = $('.date', elem).eq(0);
|
||||
if (pubDate.text().indexOf('前') !== -1) {
|
||||
pubDate = dateHelper(pubDate.text(), 8);
|
||||
} else {
|
||||
pubDate = pubDate.text();
|
||||
}
|
||||
const pubDate = pediyUtils.dateParser(
|
||||
$('.date', elem)
|
||||
.eq(0)
|
||||
.text(),
|
||||
8
|
||||
);
|
||||
|
||||
let topic;
|
||||
if (isSpecific) {
|
||||
topic = categoryId[category][1];
|
||||
} else {
|
||||
topic = $('.subject a.small', elem)
|
||||
.eq(0)
|
||||
.text();
|
||||
}
|
||||
let topic;
|
||||
if (isSpecific) {
|
||||
topic = categoryId[category][1];
|
||||
} else {
|
||||
topic = $('.subject a.small', elem)
|
||||
.eq(0)
|
||||
.text();
|
||||
}
|
||||
|
||||
return {
|
||||
title: subject.text(),
|
||||
link: baseUrl + subject.attr('href'),
|
||||
pubDate: pubDate,
|
||||
description: `作者: ${author.text()} 版块: ${topic}`,
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
return {
|
||||
title: subject.text(),
|
||||
link: baseUrl + subject.attr('href'),
|
||||
pubDate: `${pubDate}`,
|
||||
description: `作者: ${author.text()} 版块: ${topic}`,
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
const pediyUtils = {
|
||||
dateParser: (html, timeZone) => {
|
||||
let math;
|
||||
let date = new Date();
|
||||
if (/(\d+)分钟前/.exec(html)) {
|
||||
math = /(\d+)分钟前/.exec(html);
|
||||
date.setMinutes(date.getMinutes() - math[1]);
|
||||
return date.toUTCString();
|
||||
} else if (/(\d+)小时前/.exec(html)) {
|
||||
math = /(\d+)小时前/.exec(html);
|
||||
date.setHours(date.getHours() - math[1]);
|
||||
return date.toUTCString();
|
||||
} else if (/(\d+)天前/.exec(html)) {
|
||||
math = /(\d+)天前/.exec(html);
|
||||
date.setDate(date.getDate() - math[1]);
|
||||
return date.toUTCString();
|
||||
} else if (/(\d+)-(\d+)-(\d+) (\d+):(\d+)/.exec(html)) {
|
||||
math = /(\d+)-(\d+)-(\d+) (\d+):(\d+)/.exec(html);
|
||||
date = new Date(math[1], parseInt(math[2]) - 1, math[3], math[4], math[5]);
|
||||
const serverOffset = new Date().getTimezoneOffset() / 60;
|
||||
return new Date(date.getTime() - 60 * 60 * 1000 * (timeZone + serverOffset)).toUTCString();
|
||||
}
|
||||
return html;
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = pediyUtils;
|
||||
@@ -10,7 +10,7 @@ module.exports = async (ctx) => {
|
||||
responseType: 'arraybuffer',
|
||||
});
|
||||
|
||||
let type = ctx.params.type;
|
||||
let type = ctx.params.type || 1;
|
||||
let info = '新闻动态';
|
||||
let word = 'news';
|
||||
if (type === '2') {
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
const axios = require('../../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const host = 'http://www.dean.swust.edu.cn';
|
||||
let type = ctx.params.type;
|
||||
|
||||
let info = '通知公告';
|
||||
let word = 'notices/';
|
||||
|
||||
if (type === '2') {
|
||||
info = '站点新闻';
|
||||
word = 'news/';
|
||||
} else {
|
||||
type = '1';
|
||||
}
|
||||
|
||||
const web = 'http://www.dean.swust.edu.cn/xml/' + word + 'index.xml';
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: web,
|
||||
headers: {
|
||||
Referer: host,
|
||||
},
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
|
||||
const $ = cheerio.load(data, {
|
||||
xmlMode: true,
|
||||
});
|
||||
const list = $('entrity');
|
||||
|
||||
ctx.state.data = {
|
||||
title: '西南科技大学 教务处 ' + info,
|
||||
link: web,
|
||||
description: $('title')
|
||||
.first()
|
||||
.text(),
|
||||
item:
|
||||
list &&
|
||||
list
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('title').text(),
|
||||
description: item.find('summary').text(),
|
||||
pubDate: new Date(
|
||||
Date.parse(
|
||||
item
|
||||
.find('date')
|
||||
.text()
|
||||
.replace('年', '-')
|
||||
.replace('月', '-')
|
||||
.replace('日', '')
|
||||
)
|
||||
).toUTCString(),
|
||||
link: host + '/xml/' + word + item.attr('id') + '.xml',
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
const axios = require('../../../utils/axios');
|
||||
|
||||
// 转码需要设定返回数据的格式,其可选项是arraybuffer,blob,document,json,text,stream
|
||||
// 默认为json
|
||||
const axios_ins = axios.create({ responseType: 'blob' });
|
||||
|
||||
const api = 'http://www.dean.swust.edu.cn/cms/portal/news.json';
|
||||
const host = 'http://www.dean.swust.edu.cn/';
|
||||
const page = 'http://www.dean.swust.edu.cn/news/';
|
||||
|
||||
function evil(fn) {
|
||||
const Fn = Function; // 一个变量指向Function,防止有些前端编译工具报错
|
||||
return new Fn('return ' + fn)();
|
||||
}
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await axios_ins.get(api);
|
||||
const data = evil(response.data);
|
||||
|
||||
const resultItems = await Promise.all(
|
||||
data.map(async (item) => {
|
||||
const title = item.title;
|
||||
const date = item.outdate;
|
||||
const link = page + item.id;
|
||||
const author = item.publisher;
|
||||
|
||||
let resultItem = {};
|
||||
|
||||
const value = await ctx.cache.get(link);
|
||||
if (value) {
|
||||
resultItem = JSON.parse(value);
|
||||
} else {
|
||||
resultItem = {
|
||||
title: title,
|
||||
link: link,
|
||||
pubDate: new Date(date),
|
||||
author: author,
|
||||
};
|
||||
|
||||
ctx.cache.set(link, JSON.stringify(resultItem), 24 * 60 * 60);
|
||||
}
|
||||
|
||||
return Promise.resolve(resultItem);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '西南科技大学教务处 新闻',
|
||||
link: host,
|
||||
description: '西南科技大学教务处 新闻',
|
||||
item: resultItems,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
const axios = require('../../../utils/axios');
|
||||
|
||||
// 转码需要设定返回数据的格式,其可选项是arraybuffer,blob,document,json,text,stream
|
||||
// 默认为json
|
||||
const axios_ins = axios.create({ responseType: 'blob' });
|
||||
|
||||
const api = 'http://www.dean.swust.edu.cn/cms/portal/notice.json';
|
||||
const page = 'http://www.dean.swust.edu.cn/notice/page/';
|
||||
const tag = 'http://www.dean.swust.edu.cn/notice/tag/';
|
||||
|
||||
function evil(fn) {
|
||||
const Fn = Function; // 一个变量指向Function,防止有些前端编译工具报错
|
||||
return new Fn('return ' + fn)();
|
||||
}
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type || 1;
|
||||
|
||||
const response = await axios_ins.get(api);
|
||||
const responsedata = evil(response.data);
|
||||
const data = responsedata[type - 1];
|
||||
|
||||
const info = data.name || '';
|
||||
const tag_url = data.id || '';
|
||||
|
||||
const resultItems = await Promise.all(
|
||||
data.items.map(async (item) => {
|
||||
const link = page + item.id;
|
||||
const author = item.publisher;
|
||||
const date = item.outdate;
|
||||
const title = item.title;
|
||||
|
||||
let resultItem = {};
|
||||
|
||||
const value = await ctx.cache.get(link);
|
||||
if (value) {
|
||||
resultItem = JSON.parse(value);
|
||||
} else {
|
||||
resultItem = {
|
||||
title: title,
|
||||
link: link,
|
||||
pubDate: new Date(date),
|
||||
author: author,
|
||||
};
|
||||
|
||||
ctx.cache.set(link, JSON.stringify(resultItem), 24 * 60 * 60);
|
||||
}
|
||||
|
||||
return Promise.resolve(resultItem);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '西南科技大学教务处 ' + info,
|
||||
link: tag + tag_url,
|
||||
description: `西南科技大学教务处 ${info}`,
|
||||
item: resultItems,
|
||||
};
|
||||
};
|
||||
@@ -31,11 +31,12 @@ module.exports = async (ctx) => {
|
||||
});
|
||||
|
||||
const data = response.data.data.fund_nav_growth.pop();
|
||||
const yesterday = response.data.data.fund_nav_growth.pop();
|
||||
|
||||
let description = `${fundNameShort} <br> 最新净值 ${data.nav} <br> 今日`;
|
||||
let title = `${fundNameShort} ${data.date.substring(5)} `;
|
||||
|
||||
const value = parseFloat(data.value);
|
||||
const value = (parseFloat(data.nav) - parseFloat(yesterday.nav)).toFixed(4);
|
||||
|
||||
if (value > 0) {
|
||||
description += '涨幅';
|
||||
@@ -48,7 +49,7 @@ module.exports = async (ctx) => {
|
||||
title += '持平';
|
||||
}
|
||||
|
||||
description += ` ${data.percentage}%(¥${data.value})`;
|
||||
description += ` ${data.percentage}%(¥${value})`;
|
||||
|
||||
const single = {
|
||||
title,
|
||||
|
||||
Reference in New Issue
Block a user