feat: add asml press releases & announcements (#6422)

This commit is contained in:
Ethan Shen 2020-12-13 00:24:56 +08:00 committed by GitHub
parent 47dde5e4ef
commit a2311d7d12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 0 deletions

View File

@ -35,6 +35,12 @@ Compared to the official one, the RSS feed generated by RSSHub not only has more
</RouteEn>
## ASML Holding N.V.
### Press releases & announcements
<RouteEn author="nczitzk" example="/asml/press-releases" path="/asml/press-releases"/>
## BOF
### Home

View File

@ -90,6 +90,12 @@ pageClass: routes
<Route author="nczitzk" example="/aljazeera/news" path="/aljazeera/news"/>
## ASML 阿斯麦
### Press releases & announcements
<Route author="nczitzk" example="/asml/press-releases" path="/asml/press-releases"/>
## BOF
### 首页

View File

@ -3698,6 +3698,9 @@ router.get('/treasury/press-releases/:category?/:title?', require('./routes/us/t
// Bandisoft
router.get('/bandisoft/:id?/:lang?', require('./routes/bandisoft/index'));
// ASML
router.get('/asml/press-releases', require('./routes/asml/press-releases'));
// 中国机械工程学会
router.get('/cmes/news/:category?', require('./routes/cmes/news'));

View File

@ -0,0 +1,40 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const rootUrl = 'https://www.asml.com';
const currentUrl = `${rootUrl}/en/news/press-releases`;
const response = await got({
method: 'get',
url: currentUrl,
});
const list = response.data.match(/<a class="results-list__listitem" href="(.*)">/g).map((item) => ({
link: `${rootUrl}${item.split('href="')[1].replace('">', '')}`,
}));
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.title = content('title').text().replace('| ASML', '');
item.description = content('.longcopy').html();
item.pubDate = new Date(detailResponse.data.match(/"datePublished": "(.*)",/)[1]).toUTCString();
return item;
})
)
);
ctx.state.data = {
title: 'Press releases | ASML',
link: currentUrl,
item: items,
};
};