feat: 英中协会奖学金 (#3722)

Co-authored-by: DIYgod <i@diygod.me>
This commit is contained in:
Henry Wang
2020-01-14 04:00:33 +00:00
committed by DIYgod
parent 2e90c11807
commit 80df1a3195
4 changed files with 42 additions and 0 deletions

View File

@@ -50,6 +50,11 @@ The parameter id in the route is the id in the URL of the user s Google Schol
<RouteEn author="liecn" example="/gradcafe/result/computer" path="/gradcafe/result/:type" :paramsDesc="['Keyword']"/>
## Great Britain China Centre
### Educational Trust
<RouteEn author="HenryQW" example="/gbcc/trust" path="/gbcc/trust" />
## Nature
### Nature

View File

@@ -167,6 +167,12 @@ pageClass: routes
</Route>
## 英中协会
### 奖学金
<Route author="HenryQW" example="/gbcc/trust" path="/gbcc/trust" />
## 语雀
### 知识库

View File

@@ -2098,6 +2098,9 @@ router.get('/mlog-club/projects', require('./routes/mlog-club/projects'));
// Chrome 网上应用店
router.get('/chrome/webstore/extensions/:id', require('./routes/chrome/extensions'));
// 英中协会
router.get('/gbcc/trust', require('./routes/gbcc/trust'));
// Associated Press
router.get('/apnews/topics/:topic', require('./routes/apnews/topics'));

28
lib/routes/gbcc/trust.js Normal file
View File

@@ -0,0 +1,28 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const link = 'http://www.gbcc.org.uk/educational-grants';
const response = (await got.get(link)).data;
const $ = cheerio.load(response);
const items = $('.entry-anchorLinkId')
.next('.entry-text')
.map((i, e) => ({
title: $(e)
.find('h1')
.html(),
link,
description: $(e).html(),
pubDate: new Date().toUTCString(),
}))
.get();
ctx.state.data = {
title: '英中协会 - 奖学金',
description: '英中协会是由英国外交和联邦事务部于 1974 年创立的非政府部门公共机构。',
link,
item: items,
};
};