diff --git a/docs/en/new-media.md b/docs/en/new-media.md index 4c88a78f7..070815cbe 100644 --- a/docs/en/new-media.md +++ b/docs/en/new-media.md @@ -215,6 +215,18 @@ Provides a better reading experience (full text articles) over the official one. +## National Association of Colleges and Employers + +### Blog + + + +| Most Recent | Top Rated | Most Read | +| - | - | - | +| | top-blogs | mostreadblogs | + + + ## Nautilus ### Topics diff --git a/docs/new-media.md b/docs/new-media.md index 52a9128e2..36c5e89aa 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1404,6 +1404,18 @@ column 为 third 时可选的 category: +## 美国大学和雇主协会 + +### 博客 + + + +| Most Recent | Top Rated | Most Read | +| ----------- | --------- | ------------- | +| | top-blogs | mostreadblogs | + + + ## 梅斯医学 MedSci ### 推荐 diff --git a/lib/router.js b/lib/router.js index e797e1e7f..41e4c6eae 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3766,6 +3766,9 @@ router.get('/sciencenet/blog/:type?/:time?/:sort?', require('./routes/sciencenet // DailyArt router.get('/dailyart/:language?', require('./routes/dailyart/index')); +// National Association of Colleges and Employers +router.get('/nace/blog/:sort?', require('./routes/nace/blog')); + // Caixin Latest router.get('/caixin/latest', require('./routes/caixin/latest')); diff --git a/lib/routes/nace/blog.js b/lib/routes/nace/blog.js new file mode 100644 index 000000000..6e428b8bc --- /dev/null +++ b/lib/routes/nace/blog.js @@ -0,0 +1,53 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const sort = ctx.params.sort || ''; + + const rootUrl = 'https://community.naceweb.org'; + const currentUrl = `${rootUrl}/browse/blogs/${sort}`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('.BlogTitle') + .slice(0, 10) + .map((_, item) => { + item = $(item); + const link = item.attr('href'); + const split = link.split('/'); + + return { + link, + title: item.text(), + pubDate: new Date(`${split[5]}-${split[6]}-${split[7]}`).toUTCString(), + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + + item.description = content('.blogs-block .col-md-12').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +};