From 80df1a319543590c5c4efaffcf5d81f8cdf60249 Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Tue, 14 Jan 2020 04:00:33 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8B=B1=E4=B8=AD=E5=8D=8F=E4=BC=9A?= =?UTF-8?q?=E5=A5=96=E5=AD=A6=E9=87=91=20(#3722)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: DIYgod --- docs/en/study.md | 5 +++++ docs/study.md | 6 ++++++ lib/router.js | 3 +++ lib/routes/gbcc/trust.js | 28 ++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 lib/routes/gbcc/trust.js diff --git a/docs/en/study.md b/docs/en/study.md index 97b6c7e45a..e726b11802 100644 --- a/docs/en/study.md +++ b/docs/en/study.md @@ -50,6 +50,11 @@ The parameter id in the route is the id in the URL of the user ’s Google Schol +## Great Britain China Centre + +### Educational Trust + + ## Nature ### Nature diff --git a/docs/study.md b/docs/study.md index 9422a6f250..eea08479a4 100644 --- a/docs/study.md +++ b/docs/study.md @@ -167,6 +167,12 @@ pageClass: routes +## 英中协会 + +### 奖学金 + + + ## 语雀 ### 知识库 diff --git a/lib/router.js b/lib/router.js index 60c9a8ce6d..d6fee038b9 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/gbcc/trust.js b/lib/routes/gbcc/trust.js new file mode 100644 index 0000000000..d6fe972bb8 --- /dev/null +++ b/lib/routes/gbcc/trust.js @@ -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, + }; +};