feat: add kaggle 新比赛 (#3416)
This commit is contained in:
parent
ddcccfbc07
commit
4b6649b462
|
|
@ -165,6 +165,17 @@ GitHub 官方也提供了一些 RSS:
|
|||
| Hotness | Recent Comments | Recently Posted | Most Votes | Most Comments |
|
||||
|
||||
</Route>
|
||||
|
||||
### Competitions
|
||||
|
||||
<Route author="LogicJake" example="/kaggle/competitions" path="/kaggle/competitions/:category?" :paramsDesc="['类别, 默认为空']">
|
||||
|
||||
| 空 | featured | research | recruitment | gettingStarted | masters | playground | analytics |
|
||||
| -------------- | -------- | -------- | ----------- | --------------- | ------- | ---------- | --------- |
|
||||
| All Categories | Featured | Research | Recruitment | Getting started | Masters | Playground | Analytics |
|
||||
|
||||
</Route>
|
||||
|
||||
## LeetCode
|
||||
|
||||
### 文章
|
||||
|
|
|
|||
|
|
@ -1890,6 +1890,7 @@ router.get('/hatena/anonymous_diary/archive', require('./routes/hatena/anonymous
|
|||
|
||||
// kaggle
|
||||
router.get('/kaggle/discussion/:forumId/:sort?', require('./routes/kaggle/discussion'));
|
||||
router.get('/kaggle/competitions/:category?', require('./routes/kaggle/competitions'));
|
||||
|
||||
// nature
|
||||
router.get('/nature/natmachintell/research', require('./routes/nature/natmachintell/research'));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
const got = require('@/utils/got');
|
||||
const url = require('url');
|
||||
|
||||
const rootUrl = 'https://www.kaggle.com/';
|
||||
|
||||
const categoryCodes = {
|
||||
'': 'All Categories',
|
||||
featured: 'Featured',
|
||||
research: 'Research',
|
||||
recruitment: 'Recruitment',
|
||||
gettingStarted: 'Getting started',
|
||||
masters: 'Masters',
|
||||
playground: 'Playground',
|
||||
analytics: 'Analytics',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category || '';
|
||||
const categoryText = categoryCodes[category];
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://www.kaggle.com/competitions.json?sortBy=grouped&group=general&page=1&pageSize=20&category=${category}`,
|
||||
headers: {
|
||||
Referer: rootUrl,
|
||||
},
|
||||
});
|
||||
|
||||
const competitions = response.data.fullCompetitionGroups[1].competitions;
|
||||
const out = competitions.map((item) => {
|
||||
const title = item.competitionTitle;
|
||||
const description = item.competitionDescription;
|
||||
const author = item.organizationName;
|
||||
const itemUrl = url.resolve(rootUrl, item.competitionUrl);
|
||||
|
||||
const single = {
|
||||
link: itemUrl,
|
||||
title: title,
|
||||
author: author,
|
||||
description: description,
|
||||
};
|
||||
|
||||
return single;
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: `new competition-${categoryText}`,
|
||||
link: 'https://www.kaggle.com/competitions',
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue