feat(route): add sourceforge (#13363)
* feat(route): add sourceforge * Update website/docs/routes/program-update.md ---------
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const routeParams = ctx.params.routeParams;
|
||||
|
||||
const baseURL = 'https://sourceforge.net';
|
||||
const link = `https://sourceforge.net/directory/?${routeParams.toString()}`;
|
||||
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
const itemList = $('ul.projects li[itemprop=itemListElement]');
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('.content h1').text().trim(),
|
||||
link,
|
||||
item: itemList.toArray().map((element) => {
|
||||
const item = $(element);
|
||||
const title = item.find('.result-heading-title').text().trim();
|
||||
const link = `${baseURL}${item.find('.result-heading-title').attr('href')}`;
|
||||
const description = item.find('.result-heading-texts').html();
|
||||
const pubDate = parseDate(item.find('time').attr('datetime'), 'YYYY-MM-DD');
|
||||
|
||||
return {
|
||||
title,
|
||||
link,
|
||||
description,
|
||||
pubDate,
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:routeParams?': ['JimenezLi'],
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
'sourceforge.net': {
|
||||
_name: 'SourceForge',
|
||||
www: [
|
||||
{
|
||||
title: 'Software',
|
||||
docs: 'https://docs.rsshub.app/routes/program-update#sourceforge',
|
||||
source: '/directory',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/:routeParams?', require('./index'));
|
||||
};
|
||||
@@ -638,6 +638,16 @@ Open `https://www.sony.com/electronics/support` and search for the corresponding
|
||||
|
||||
</Route>
|
||||
|
||||
## SourceForge {#sourceforge}
|
||||
|
||||
<Route author="JimenezLi" example="/sourceforge/topic=artificial-intelligence&os=windows" path="/sourceforge/:routeParams?" paramsDesc={['route params, see below']}>
|
||||
|
||||
For some URL like [https://sourceforge.net/directory/artificial-intelligence/windows/](https://sourceforge.net/directory/artificial-intelligence/windows/), it is equal to [https://sourceforge.net/directory/?topic=artificial-intelligence&os=windows"](https://sourceforge.net/directory/?topic=artificial-intelligence&os=windows), thus subscribing to `/sourceforge/topic=artificial-intelligence&os=windows`.
|
||||
|
||||
URL params can duplicate, such as `/sourceforge/topic=artificial-intelligence&os=windows&os=linux`.
|
||||
|
||||
</Route>
|
||||
|
||||
## Thunderbird {#thunderbird}
|
||||
|
||||
### Changelog {#thunderbird-changelog}
|
||||
|
||||
Reference in New Issue
Block a user