diff --git a/docs/en/government.md b/docs/en/government.md index ad7f12075..405bd460e 100644 --- a/docs/en/government.md +++ b/docs/en/government.md @@ -107,6 +107,10 @@ Fill in the English expression for the month in the Month field, eg `December` f +### Office of Science and Technology Policy + + + ## U.S. Department of the Treasury ### Press Releases diff --git a/docs/government.md b/docs/government.md index b91586f8e..01c91342e 100644 --- a/docs/government.md +++ b/docs/government.md @@ -240,6 +240,10 @@ pageClass: routes +### 科学技术政策办公室 + + + ## 美国财政部 ### 新闻稿 diff --git a/lib/v2/whitehouse/maintainer.js b/lib/v2/whitehouse/maintainer.js index 454bfa704..1e66da755 100644 --- a/lib/v2/whitehouse/maintainer.js +++ b/lib/v2/whitehouse/maintainer.js @@ -1,3 +1,4 @@ module.exports = { '/briefing-room/:category?': ['nczitzk'], + '/ostp': ['LyleLee'], }; diff --git a/lib/v2/whitehouse/ostp.js b/lib/v2/whitehouse/ostp.js new file mode 100644 index 000000000..b41d3b37a --- /dev/null +++ b/lib/v2/whitehouse/ostp.js @@ -0,0 +1,50 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const rootUrl = 'https://www.whitehouse.gov'; + const currentUrl = `${rootUrl}/ostp/news-updates`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('.news-item__title') + .slice(0, 10) + .map((_, item) => { + item = $(item); + return { + title: item.text(), + link: item.attr('href'), + }; + }) + .get(); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + + item.description = content('.body-content').html(); + item.pubDate = parseDate(content('time.published').attr('datetime')); + item.author = content('span.tax-links.cat-links > a').text(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: 'Whitehouse OSTP', + link: currentUrl, + description: 'Whitehouse Office of Science and Technology Policy', + item: items, + }; +}; diff --git a/lib/v2/whitehouse/radar.js b/lib/v2/whitehouse/radar.js index dcef31af0..e841a2881 100644 --- a/lib/v2/whitehouse/radar.js +++ b/lib/v2/whitehouse/radar.js @@ -8,6 +8,12 @@ module.exports = { source: ['/briefing-room/:category', '/'], target: '/whitehouse/briefing-room/:category', }, + { + title: '科技政策办公室', + docs: 'https://docs.rsshub.app/government.html#mei-guo-bai-gong-ban-gong-ting', + source: ['/ostp', '/'], + target: '/whitehouse/ostp', + }, ], }, }; diff --git a/lib/v2/whitehouse/router.js b/lib/v2/whitehouse/router.js index d815b0ce6..28403b1f7 100644 --- a/lib/v2/whitehouse/router.js +++ b/lib/v2/whitehouse/router.js @@ -1,3 +1,4 @@ module.exports = (router) => { router.get('/briefing-room/:category?', require('./briefing-room')); + router.get('/ostp', require('./ostp')); };