feat(route): add sourceforge (#13363)

* feat(route): add sourceforge

* Update website/docs/routes/program-update.md

---------
This commit is contained in:
JimenezLi
2023-09-22 18:03:16 +08:00
committed by GitHub
parent 3a2eec2bd4
commit 4b7961b3e8
5 changed files with 61 additions and 0 deletions
+33
View File
@@ -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,
};
}),
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/:routeParams?': ['JimenezLi'],
};
+12
View File
@@ -0,0 +1,12 @@
module.exports = {
'sourceforge.net': {
_name: 'SourceForge',
www: [
{
title: 'Software',
docs: 'https://docs.rsshub.app/routes/program-update#sourceforge',
source: '/directory',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/:routeParams?', require('./index'));
};
+10
View File
@@ -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}