Files
RSSHub/lib/v2/studygolang/weekly.js
Fatpandac c586995584 fix(route): change to use a more precise selector (#12242)
* fix(route): change to use a more precise selector

* refactor: migrate to v2

---------
2023-04-06 04:28:40 +08:00

30 lines
745 B
JavaScript

const got = require('@/utils/got');
const cheerio = require('cheerio');
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.state.data = {
title: 'Go语言爱好者周刊',
link: url,
item: resultItem,
};
};