forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add route for School of Economics & Management, Tongji Universi…
…ty (同济大学经济与管理学院) (DIYgod#17516) * Add RSS for Tongji SEM * Update notice.ts * Update _utils.ts * Update notice.ts Fix url * Update notice.ts Fetch data from the first page only. * Update notice.ts * Use the redirected URL instead * Update code
- Loading branch information
1 parent
468bfcd
commit 6895333
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import got from '@/utils/got'; | ||
import { load } from 'cheerio'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import { config } from '@/config'; | ||
|
||
export async function getNotifByPage() { | ||
const pageUrl: string = `https://sem.tongji.edu.cn/semch/category/frontpage/notice`; | ||
|
||
try { | ||
const response = await got.get(pageUrl, { | ||
headers: { | ||
'User-Agent': config.ua, | ||
}, | ||
}); | ||
|
||
const html = response.body; | ||
const $ = load(html); | ||
|
||
const notifListElements = $('#page-wrap > div.maim_pages > div > div.leftmain_page > div > ul > li'); | ||
|
||
return notifListElements.toArray().map((Element) => { | ||
const aTagFirst = $(Element).find('a.bt'); | ||
const aTagSecond = $(Element).find('a.time'); | ||
|
||
const title = aTagFirst.attr('title'); | ||
const href = aTagFirst.attr('href'); | ||
const time = aTagSecond.text().trim(); | ||
|
||
return { | ||
title, | ||
link: href, | ||
pubDate: parseDate(time, 'YYYY-MM-DD'), | ||
}; | ||
}); | ||
} catch { | ||
// console.error(error); | ||
} | ||
return []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Warning: The author still knows nothing about javascript! | ||
import { Route } from '@/types'; | ||
import { getNotifByPage } from './_utils'; | ||
|
||
export const route: Route = { | ||
path: '/sem', | ||
categories: ['university'], | ||
example: '/tongji/sem', | ||
parameters: {}, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
name: '经济与管理学院通知', | ||
maintainers: ['sitdownkevin'], | ||
url: 'sem.tongji.edu.cn/semch/category/frontpage/notice', | ||
handler, | ||
description: ``, | ||
}; | ||
|
||
async function handler() { | ||
const results = await getNotifByPage(); | ||
|
||
// feed the data to rss | ||
return { | ||
title: '同济大学经济与管理学院', | ||
link: 'https://sem.tongji.edu.cn/semch/category/frontpage/notice', | ||
item: results, | ||
}; | ||
} |