mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-04 02:58:08 +08:00
feat(route): add Go语言中文网板块 (#12274)
This commit is contained in:
@@ -1,29 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { FetchGoItems } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const url = 'https://studygolang.com/go/weekly';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const resultItem = $('div.topic div.title')
|
||||
.map((_index, elem) => {
|
||||
elem = $(elem);
|
||||
const $link = elem.find('a');
|
||||
const title = $link.text();
|
||||
const link = $link.attr('href');
|
||||
return {
|
||||
title,
|
||||
link,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
ctx.params.id = 'weekly';
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Go语言爱好者周刊',
|
||||
link: url,
|
||||
item: resultItem,
|
||||
};
|
||||
ctx.state.data = await FetchGoItems(ctx);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user