mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-07 05:36:08 +08:00
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
|
|
module.exports = async (ctx) => {
|
|
const since = ctx.params.since;
|
|
const language = ctx.params.language || '';
|
|
const url = `https://github.com/trending/${encodeURIComponent(language)}?since=${since}`;
|
|
|
|
const response = await got({
|
|
method: 'get',
|
|
url: url,
|
|
headers: {
|
|
Referer: url,
|
|
},
|
|
});
|
|
|
|
const data = response.data;
|
|
|
|
const $ = cheerio.load(data);
|
|
const list = $('article');
|
|
|
|
ctx.state.data = {
|
|
title: $('title').text(),
|
|
link: url,
|
|
item:
|
|
list &&
|
|
list
|
|
.map((index, item) => {
|
|
item = $(item);
|
|
return {
|
|
title: item.find('h1').text(),
|
|
description: `${item.find('.pr-4').text()}<br>
|
|
<br>Language: ${item.find('span[itemprop="programmingLanguage"]').text() || 'unknown'}
|
|
<br>Star: ${item.find('.muted-link').eq(0).text()}
|
|
<br>Fork: ${item.find('.muted-link').eq(1).text()}`,
|
|
link: `https://github.com${item.find('h1 a').attr('href')}`,
|
|
};
|
|
})
|
|
.get(),
|
|
};
|
|
};
|