mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
feat: add 电鸭社区 (#3453)
This commit is contained in:
@@ -215,6 +215,11 @@ type 为 all 时,category 参数不支持 cost 和 free
|
||||
|
||||
</Route>
|
||||
|
||||
## 电鸭社区
|
||||
|
||||
### 工作机会
|
||||
|
||||
<Route author="sfyumi" example="/eleduck/jobs" path="/eleduck/jobs"/>
|
||||
## 福利资源-met.red
|
||||
|
||||
### 福利资源-met.red
|
||||
|
||||
@@ -1783,6 +1783,9 @@ router.get('/mail/imap/:email', require('./routes/mail/imap'));
|
||||
// 智联招聘
|
||||
router.get('/zhilian/:city/:keyword', require('./routes/zhilian/index'));
|
||||
|
||||
// 电鸭社区
|
||||
router.get('/eleduck/jobs', require('./routes/eleduck/jobs'));
|
||||
|
||||
// 北华航天工业学院 - 新闻
|
||||
router.get('/nciae/news', require('./routes/universities/nciae/news'));
|
||||
|
||||
|
||||
38
lib/routes/eleduck/jobs.js
Normal file
38
lib/routes/eleduck/jobs.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://svc.eleduck.com/api/v1/posts?category=5&page=1`,
|
||||
});
|
||||
|
||||
const data = response.data.posts;
|
||||
|
||||
const out = await Promise.all(
|
||||
data.map(async (job) => {
|
||||
const url = `https://svc.eleduck.com/api/v1/posts/${job.id}`;
|
||||
const cache = await ctx.cache.get(url);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
const response = await got.get(url);
|
||||
const jobDetail = response.data.post;
|
||||
|
||||
const single = {
|
||||
title: jobDetail.title,
|
||||
link: `https://eleduck.com/posts/${job.id}`,
|
||||
author: jobDetail.user.nickname,
|
||||
description: jobDetail.content.main,
|
||||
pubDate: new Date(jobDetail.published_at).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(url, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '电鸭社区-工作机会',
|
||||
link: 'https://eleduck.com/?category=5',
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user