feat: add semiconductor industry association latest news
This commit is contained in:
parent
b1ae777b87
commit
c63a8e998a
|
|
@ -260,6 +260,7 @@ This route provides a flexible plan with full text content to subscribe specific
|
|||
### Blog
|
||||
|
||||
<RouteEn author="nczitzk" example="/polar/blog" path="/polar/blog"/>
|
||||
|
||||
## Quanta Magazine
|
||||
|
||||
### Archive
|
||||
|
|
@ -273,6 +274,12 @@ Compared to the official one, this feed:
|
|||
|
||||
</RouteEn>
|
||||
|
||||
## Semiconductor Industry Association
|
||||
|
||||
### Latest News
|
||||
|
||||
<RouteEn author="nczitzk" example="/semiconductors/latest-news" path="/semiconductors/latest-news"/>
|
||||
|
||||
## Simons Foundation
|
||||
|
||||
### Articles
|
||||
|
|
|
|||
|
|
@ -1370,6 +1370,12 @@ column 为 third 时可选的 category:
|
|||
|
||||
</Route>
|
||||
|
||||
## 美国半导体行业协会
|
||||
|
||||
### 新闻
|
||||
|
||||
<Route author="nczitzk" example="/semiconductors/latest-news" path="/semiconductors/latest-news"/>
|
||||
|
||||
## 美国大学和雇主协会
|
||||
|
||||
### 博客
|
||||
|
|
|
|||
|
|
@ -3780,4 +3780,7 @@ 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'));
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue