feat(route): Add routes to SISU news. (#14546)
* feat(route): Add route to SISU news ```routes /shisu/news ``` ## New RSS Route Checklist / 新 RSS 路由检查表 - [x] New Route / 新的路由 - [x] Follows [v2 Script Standard](https://docs.rsshub.app/joinus/advanced/script-standard) / 跟随 [v2 路由规范](https://docs.rsshub.app/zh/joinus/advanced/script-standard) - [ ] Documentation / 文档说明 - [x] Full text / 全文获取 - [x] Use cache / 使用缓存 - [ ] Anti-bot or rate limit / 反爬/频率限制 - [ ] If yes, do your code reflect this sign? / 如果有, 是否有对应的措施? - [x] [Date and time](https://docs.rsshub.app/joinus/advanced/pub-date) / [日期和时间](https://docs.rsshub.app/zh/joinus/advanced/pub-date) - [x] Parsed / 可以解析 - [x] Correct time zone / 时区正确 - [ ] New package added / 添加了新的包 - [ ] `Puppeteer` * Update university.mdx * Update news.js * Update news.js Modified the url... * fix(route): Add more options to SISU news. ```route /shisu/news /shisu/news/notice /shisu/news/campus ``` * fix: some small problems. * feat(route): Add more options to SISU news. ```routes /shisu/news /shisu/news/notice /shisu/news/campus ``` * fix(routes): modified to the correct route. * Forgot to format the document. * fix(route): made category mandatory * Update news.js
This commit is contained in:
parent
3c9bce7252
commit
fd18a0e9d1
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/news/:category': ['Duuckjing'],
|
||||
};
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
const url = 'https://news.shisu.edu.cn';
|
||||
const banner = 'https://news.shisu.edu.cn/news/index/39adf3d9ae414bc39c6d3b9316ae531f.png';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { section = 'news' } = ctx.params;
|
||||
const { data: r } = await got(`${url}/${section}/index.html`);
|
||||
const $ = cheerio.load(r);
|
||||
let itemsoup;
|
||||
switch (section) {
|
||||
case 'news':
|
||||
itemsoup = $('#gallery-wrapper > article')
|
||||
.toArray()
|
||||
.map((i0) => {
|
||||
const i = $(i0);
|
||||
const img = i.find('img').attr('src');
|
||||
return {
|
||||
title: i.find('a').text().trim(),
|
||||
link: `${url}${i.find('a').attr('href')}`,
|
||||
category: i.find('.in-con02 > span:nth-child(1)').text(),
|
||||
itunes_item_image: `${url}${img}`
|
||||
};
|
||||
});
|
||||
break;
|
||||
default:
|
||||
itemsoup = $('li.clear')
|
||||
.toArray()
|
||||
.map((i0) => {
|
||||
const i = $(i0);
|
||||
return {
|
||||
title: i.find('h3>a').attr('title').trim(),
|
||||
link: `${url}${i.find('h3>a').attr('href')}`,
|
||||
category: i.find('p>span:nth-child(1)').text(),
|
||||
};
|
||||
});
|
||||
};
|
||||
const items = await Promise.all(
|
||||
itemsoup.map((j) =>
|
||||
ctx.cache.tryGet(j.link, async () => {
|
||||
const { data: r } = await got(j.link);
|
||||
const $ = cheerio.load(r);
|
||||
const img = $('.tempWrap > ul > li:nth-child(1)> img').attr('src');
|
||||
j.description = $('.ot_main_r .content').html();
|
||||
j.author = $('.math_time_l > span:nth-child(3)').text().trim();
|
||||
j.pubDate = timezone(parseDate($('.math_time_l > span:nth-child(2)').text(), 'YYYY-MM-DD'), +8);
|
||||
if (!j.itunes_item_image) {
|
||||
j.itunes_item_image = img ? `${url}${img}` : banner;
|
||||
}
|
||||
return j;
|
||||
}))
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `上外新闻|SISU TODAY -${section.charAt(0).toUpperCase() + section.slice(1)}`,
|
||||
image: 'https://bkimg.cdn.bcebos.com/pic/8d5494eef01f3a296b70affa9825bc315c607c4d?x-bce-process=image/resize,m_lfit,w_536,limit_1/quality,Q_70',
|
||||
link: `${url}/${section}/index.html`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'shisu.edu.cn': {
|
||||
_name: '上海外国语大学',
|
||||
news: [
|
||||
{
|
||||
title: '上外新闻',
|
||||
docs: 'https://docs.rsshub.app/routes/university#shang-hai-wai-guo-yu-da-xue',
|
||||
source: ['/:category/index.html'],
|
||||
target: '/shisu/news/:category',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/news/:category', require('./news'));
|
||||
};
|
||||
|
|
@ -2625,6 +2625,16 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE\_TL
|
|||
| 1793 | sstmzs |
|
||||
</Route>
|
||||
|
||||
## 上海外国语大学 {#shang-hai-eai-guo-yu-da-xue}
|
||||
|
||||
### 上外新闻 {#shang-hai-eai-guo-yu-da-xue-sisu-news}
|
||||
|
||||
<Route author="Duuckjing" example="/shisu/news/notice" path="/shisu/news/:category" paramsDesc={['新闻的分类可根据自己的需要选择,首页为全部新闻']} radar="1">
|
||||
| 首页 | 特稿 | 学术 | 教学 | 国际 | 校园 | 人物 | 视讯 | 公告 |
|
||||
| ---- | -------- | -------- | -------- | ------------- | ------ | ------ | ---------- | ------ |
|
||||
| news | gazette | research- | academics- | international | campus | people | multimedia | notice |
|
||||
</Route>
|
||||
|
||||
## 深圳大学 {#shen-zhen-da-xue}
|
||||
|
||||
### 研究生招生网 {#shen-zhen-da-xue-yan-jiu-sheng-zhao-sheng-wang}
|
||||
|
|
|
|||
Loading…
Reference in New Issue