diff --git a/docs/en/new-media.md b/docs/en/new-media.md index 51ea8aed4e..a090eec646 100644 --- a/docs/en/new-media.md +++ b/docs/en/new-media.md @@ -268,6 +268,7 @@ This route provides a flexible plan with full text content to subscribe specific ### Blog + ## Quanta Magazine ### Archive @@ -281,6 +282,12 @@ Compared to the official one, this feed: +## Semiconductor Industry Association + +### Latest News + + + ## Simons Foundation ### Articles diff --git a/docs/new-media.md b/docs/new-media.md index 1dd27e7377..627e5a05d6 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1438,6 +1438,12 @@ column 为 third 时可选的 category: +## 美国半导体行业协会 + +### 新闻 + + + ## 美国大学和雇主协会 ### 博客 diff --git a/lib/router.js b/lib/router.js index 112c5292d9..6a99ab68b9 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3790,6 +3790,9 @@ router.get('/nace/blog/:sort?', require('./routes/nace/blog')); // Caixin Latest router.get('/caixin/latest', require('./routes/caixin/latest')); +// Semiconductor Industry Association +router.get('/semiconductors/latest-news', require('./routes/semiconductors/latest-news')); + // VOA News router.get('/voa/day-photos', require('./routes/voa/day-photos')); diff --git a/lib/routes/semiconductors/latest-news.js b/lib/routes/semiconductors/latest-news.js new file mode 100644 index 0000000000..cd17871211 --- /dev/null +++ b/lib/routes/semiconductors/latest-news.js @@ -0,0 +1,48 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const rootUrl = 'https://www.semiconductors.org'; + const currentUrl = `${rootUrl}/news-events/latest-news`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('h3') + .slice(0, 15) + .map((_, item) => { + item = $(item).parent(); + return { + title: item.text(), + link: item.attr('href'), + }; + }) + .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('#main').html(); + item.pubDate = new Date(content('meta[property="article:published_time"]').attr('content')).toUTCString(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +};