mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +08:00
feat(route): add Go语言中文网板块 (#12274)
This commit is contained in:
@@ -1,37 +1,7 @@
|
||||
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';
|
||||
const { FetchGoItems } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const jobs_url = 'https://studygolang.com/go/jobs';
|
||||
ctx.params.id = '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))),
|
||||
};
|
||||
ctx.state.data = await FetchGoItems(ctx);
|
||||
};
|
||||
|
||||
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),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user