Add: the-economist gre (#2043)

* Add /the-economist/gre-vocabulary

* 原来有接口 = =

* 忘了写文档 = =
This commit is contained in:
凉凉
2019-05-06 01:03:26 +08:00
committed by DIYgod
parent b073fb8d11
commit e9b5e285e1
3 changed files with 34 additions and 0 deletions

View File

@@ -213,3 +213,7 @@ category 对应的关键词有
## 21 财经 ## 21 财经
<Route name="频道" author="brilon" example="/21caijing/channel/readnumber" path="/21caijing/channel/:name" :paramsDesc="['频道名称,可在[https://m.21jingji.com/](https://m.21jingji.com/)页面URL中找到']"/> <Route name="频道" author="brilon" example="/21caijing/channel/readnumber" path="/21caijing/channel/:name" :paramsDesc="['频道名称,可在[https://m.21jingji.com/](https://m.21jingji.com/)页面URL中找到']"/>
## The Economist
<Route name="GRE Vocabulary" author="xyqfer" example="/the-economist/gre-vocabulary" path="/the-economist/gre-vocabulary" />

View File

@@ -1306,4 +1306,7 @@ router.get('/saraba1st/thread/:tid', require('./routes/saraba1st/thread'));
router.get('/gradcafe/result/:type', require('./routes/gradcafe/result')); router.get('/gradcafe/result/:type', require('./routes/gradcafe/result'));
router.get('/gradcafe/result', require('./routes/gradcafe/result')); router.get('/gradcafe/result', require('./routes/gradcafe/result'));
// The Economist
router.get('/the-economist/gre-vocabulary', require('./routes/the-economist/gre-vocabulary'));
module.exports = router; module.exports = router;

View File

@@ -0,0 +1,27 @@
const axios = require('../../utils/axios');
module.exports = async (ctx) => {
const response = await axios({
method: 'get',
url: 'https://gre.economist.com/api/gre-vocabulary.json',
});
const wordInfo = response.data[0];
const time = wordInfo.publishedDate;
ctx.state.data = {
title: 'The Economist GRE Vocabulary',
link: 'https://gre.economist.com/gre-vocabulary',
item: [
{
title: `${wordInfo.word} - ${time}`,
description: `
<img referrerpolicy="no-referrer" src="${wordInfo.image.url}"><br>
Source: <a href="${wordInfo.sourceUrl}">${wordInfo.sourceTitle}</a>
`,
pubDate: new Date(time).toUTCString(),
link: wordInfo.url,
},
],
};
};