diff --git a/docs/en/new-media.md b/docs/en/new-media.md index a2862e49c..5bc4f8a0d 100644 --- a/docs/en/new-media.md +++ b/docs/en/new-media.md @@ -35,6 +35,12 @@ Compared to the official one, the RSS feed generated by RSSHub not only has more +## ASML Holding N.V. + +### Press releases & announcements + + + ## BOF ### Home diff --git a/docs/new-media.md b/docs/new-media.md index aaed639be..acd342748 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -90,6 +90,12 @@ pageClass: routes +## ASML 阿斯麦 + +### Press releases & announcements + + + ## BOF ### 首页 diff --git a/lib/router.js b/lib/router.js index e2c515fe9..f3bfeb4c8 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/asml/press-releases.js b/lib/routes/asml/press-releases.js new file mode 100644 index 000000000..07f13d54d --- /dev/null +++ b/lib/routes/asml/press-releases.js @@ -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(//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, + }; +};