mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-07 21:47:57 +08:00
feat: add route nowcoder/schedule (#4711)
This commit is contained in:
@@ -231,6 +231,10 @@ pageClass: routes
|
||||
|
||||
</Route>
|
||||
|
||||
### 校招日程
|
||||
|
||||
<Route author="junfengP" example="/nowcoder/schedule" path="nowcoder/schedule/:propertyId?/:typeId?" :paramsDesc="['行业, 在控制台中抓取接口,可获得行业id,默认0', '类别,同上']" />
|
||||
|
||||
## 书友社区
|
||||
|
||||
### 导读
|
||||
|
||||
@@ -1275,6 +1275,7 @@ router.get('/hupu/bbs/:id/:order?', require('./routes/hupu/bbs'));
|
||||
|
||||
// 牛客网
|
||||
router.get('/nowcoder/discuss/:type/:order', require('./routes/nowcoder/discuss'));
|
||||
router.get('/nowcoder/schedule/:propertyId?/:typeId?', require('./routes/nowcoder/schedule'));
|
||||
|
||||
// Xiaomi.eu
|
||||
router.get('/xiaomieu/releases', require('./routes/xiaomieu/releases'));
|
||||
|
||||
31
lib/routes/nowcoder/schedule.js
Normal file
31
lib/routes/nowcoder/schedule.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const propertyId = ctx.params.propertyId ? ctx.params.propertyId : 0;
|
||||
const typeId = ctx.params.typeId ? ctx.params.typeId : 0;
|
||||
|
||||
const link = `https://www.nowcoder.com/school/schedule/data?token=&query=&typeId=${typeId}&propertyId=${propertyId}&onlyFollow=false&_=${new Date().getTime()}`;
|
||||
const responseBody = (await got.get(link)).data;
|
||||
if (responseBody.code !== 0) {
|
||||
throw Error(`接口错误,错误代码:${responseBody.code},错误原因:${responseBody.msg}`);
|
||||
}
|
||||
const data = responseBody.data;
|
||||
|
||||
ctx.state.data = {
|
||||
title: '名企校招日程',
|
||||
link: 'https://www.nowcoder.com/school/schedule',
|
||||
description: '名企校招日程',
|
||||
item: data.map((item) => {
|
||||
let desc = `<tr><td><img src="${item.logo}" referrerpolicy="no-referrer""></td></tr>`;
|
||||
item.schedules.forEach((each) => {
|
||||
desc += `<tr><td>${each.content}</td><td>${each.time}</td></tr>`;
|
||||
});
|
||||
return {
|
||||
title: item.name,
|
||||
description: `<table>${desc}</table>`,
|
||||
pubDate: new Date(item.createTime).toUTCString(),
|
||||
link: `https://www.nowcoder.com/school/schedule/${item.id}`,
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user