feat(route): GoCN招聘、Go语言中文网招聘 (#10443)

* feat(route): GoCn招聘、Go语言中文网招聘

* fix: typo

* fix: timezone

Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com>
This commit is contained in:
CcccFz
2022-08-11 20:03:03 +08:00
committed by GitHub
co-authored by pull[bot]
parent 5428e35f03
commit 99856214aa
12 changed files with 124 additions and 14 deletions
+9 -1
View File
@@ -345,11 +345,19 @@ GitHub 官方也提供了一些 RSS:
<Route author="Weilet" example="/go-weekly" path="/go-weekly"/>
### 招聘
<Route author="CcccFz" example="/studygolang/jobs" path="/studygolang/jobs" radar="1" rssbud="1"/>
## GoCN
### 文章
<Route author="AtlanCI" example="/gocn" path="/gocn"/>
<Route author="AtlanCI CcccFz" example="/gocn" path="/gocn" radar="1" rssbud="1"/>
### 招聘
<Route author="CcccFz" example="/gocn/jobs" path="/gocn/jobs" radar="1" rssbud="1"/>
## Hacker News
+1
View File
@@ -32,6 +32,7 @@ module.exports = {
'/user/followers/:uid': ['Qixingchen'],
'/user/followings/:uid': ['Qixingchen'],
'/user/video/:uid/:disableEmbed?': ['DIYgod'],
'/user/video-all/:uid/:disableEmbed?': ['CcccFz'],
'/video/danmaku/:bvid/:pid?': ['Qixingchen'],
'/video/page/:bvid/:disableEmbed?': ['sxzz'],
'/video/reply/:bvid': ['Qixingchen'],
+23
View File
@@ -0,0 +1,23 @@
const got = require('@/utils/got');
const util = require('./util');
module.exports = async (ctx) => {
const base_url = 'https://gocn.vip/topics';
const api_url = 'https://gocn.vip/apiv3/topic/jobs?currentPage=1&grade=new';
const response = await got({
url: api_url,
headers: {
Referer: base_url,
},
});
const list = response.data.data.list;
ctx.state.data = {
title: `GoCN社区-招聘`,
link: base_url,
description: `获取GoCN站点最新招聘`,
item: await Promise.all(list.map((item) => ctx.cache.tryGet(`${base_url}/${item.guid}`, () => util.getFeedItem(item)))),
};
};
+2 -1
View File
@@ -1,3 +1,4 @@
module.exports = {
'/': ['AtlanCI'],
'/': ['AtlanCI', 'CcccFz'],
'/jobs': ['CcccFz'],
};
+6
View File
@@ -8,6 +8,12 @@ module.exports = {
source: ['/'],
target: '/gocn',
},
{
title: '招聘',
docs: 'https://docs.rsshub.app/programming.html#GoCN',
source: ['/'],
target: '/gocn/jobs',
},
],
},
};
+1
View File
@@ -1,3 +1,4 @@
module.exports = function (router) {
router.get('/', require('./topics'));
router.get('/jobs', require('./jobs'));
};
+9 -12
View File
@@ -1,28 +1,25 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const util = require("./util");
module.exports = async (ctx) => {
const api_url = 'https://gocn.vip/api/topic/list?currentPage=1&cate2Id=0&grade=new';
const base_url = 'https://gocn.vip/topics';
const api_url = 'https://gocn.vip/apiv3/topic/list?currentPage=1&cate2Id=0&grade=new';
const response = await got({
method: 'get',
url: api_url,
headers: {
Referer: base_url,
},
});
const data = response.data.data.list;
const list = response.data.data.list;
ctx.state.data = {
title: `GoCN社区文章`,
link: `https://gocn.vip`,
title: `GoCN社区-文章`,
link: base_url,
description: `获取GoCN站点最新文章`,
item: data.map((item) => ({
title: item.title,
description: item.summary,
link: `${base_url}/${item.id}`,
pubDate: parseDate(item.ctime * 1000),
})),
item: await Promise.all(
list.map(async (item) => await ctx.cache.tryGet(`${base_url}/${item.guid}`, () => util.getFeedItem(item))),
),
};
};
+17
View File
@@ -0,0 +1,17 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
async function getFeedItem(item) {
const response = await got(`https://gocn.vip/apiv3/topic/${item.guid}/info`);
return {
link: `https://gocn.vip/topics/${item.guid}`,
title: item.title,
description: response.data.data.topic.contentHtml,
pubDate: parseDate(item.ctime, 'X'),
};
}
module.exports = {
getFeedItem,
};
+37
View File
@@ -0,0 +1,37 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
const base_url = 'https://studygolang.com';
module.exports = async (ctx) => {
const jobs_url = 'https://studygolang.com/go/jobs';
const response = await got({
url: jobs_url,
headers: {
Referer: base_url,
},
});
const $ = cheerio.load(response.data);
const list = $('.topics .topic').get();
ctx.state.data = {
title: 'Go语言中文网 | 招聘',
link: jobs_url,
description: `获取Go语言中文网的最新招聘`,
item: await Promise.all(list.map((item) => getFeedItem(item))),
};
};
function getFeedItem(item) {
const $ = cheerio.load(item);
const title = $('.title a');
return {
title: title.attr('title'),
link: `${base_url}${title.attr('href')}`,
pubDate: timezone(parseDate($('.meta .timeago').attr('title'), 'YYYY-MM-DD hh:mm:ss'), +8),
};
}
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/jobs': ['CcccFz'],
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'studygolang.com': {
_name: 'Go 语言中文网',
'.': [
{
title: '招聘',
docs: 'https://docs.rsshub.app/programming.html#go-yu-yan-zhong-wen-wang',
source: ['/'],
target: '/studygolang/jobs',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/jobs', require('./jobs'));
};