feat: add the batch from deeplearning.ai (#4795)

This commit is contained in:
Ethan Shen
2020-05-18 12:39:20 +08:00
committed by GitHub
parent dddd964138
commit 58e05978a1
3 changed files with 39 additions and 0 deletions
+6
View File
@@ -24,6 +24,12 @@ pageClass: routes
<Route author="fengkx" example="/cve/search/PostgreSQL" path="/cve/search/:keyword" :paramsDesc="['关键词']" />
## deeplearning.ai
### TheBatch 周报
<Route author="nczitzk" example="/deeplearning/thebatch" path="/deeplearning/thebatch"/>
## Dockone
### 周报
+3
View File
@@ -2675,6 +2675,9 @@ router.get('/qingting/channel/:id', require('./routes/qingting/channel'));
// 金色财经
router.get('/jinse/lives', require('./routes/jinse/lives'));
// deeplearning.ai
router.get('/deeplearningai/thebatch', require('./routes/deeplearningai/thebatch'));
// Fate Grand Order
router.get('/fgo/news', require('./routes/fgo/news'));
+30
View File
@@ -0,0 +1,30 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: `https://www.deeplearning.ai/WPCore/wp-admin/admin-ajax.php?action=hubspot_reader_blog_the_batch&offset=0&limit=5`,
});
const list = response.data.data.map((item) => ({
title: `${item.title} - ${item.name}`,
link: item.web_view_url,
pubDate: new Date(item.date).toUTCString(),
}));
ctx.state.data = {
title: `The Batch - a new weekly newsletter from deeplearning.ai`,
link: `https://www.deeplearning.ai/thebatch/`,
item: await Promise.all(
list.map(
async (item) =>
await ctx.cache.tryGet(item.link, async () => {
const contentResponse = await got({ method: 'get', url: item.link });
const content = cheerio.load(contentResponse.data);
item.description = content('td[style="width: 576px;"]').parent().html();
return item;
})
)
),
};
};