feat(route): 美国白宫科学技术政策办公室 US Whitehouse Office Of Science And… (#9246)

* Add whitehouse/ostp 美国白宫科学技术政策办公室 US Whitehouse Office Of Science And Technology Policy

* Add whitehouse OSTP, update english docs
This commit is contained in:
LyleLee 2022-03-06 20:11:34 +08:00 committed by GitHub
parent 6a4b939509
commit ba9891f578
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 66 additions and 0 deletions

View File

@ -107,6 +107,10 @@ Fill in the English expression for the month in the Month field, eg `December` f
</RouteEn>
### Office of Science and Technology Policy
<RouteEn author="LyleLee" example="/whitehouse/ostp" path="/whitehouse/ostp"/>
## U.S. Department of the Treasury
### Press Releases

View File

@ -240,6 +240,10 @@ pageClass: routes
</Route>
### 科学技术政策办公室
<Route author="LyleLee" example="/whitehouse/ostp" path="/whitehouse/ostp"/>
## 美国财政部
### 新闻稿

View File

@ -1,3 +1,4 @@
module.exports = {
'/briefing-room/:category?': ['nczitzk'],
'/ostp': ['LyleLee'],
};

50
lib/v2/whitehouse/ostp.js Normal file
View File

@ -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,
};
};

View File

@ -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',
},
],
},
};

View File

@ -1,3 +1,4 @@
module.exports = (router) => {
router.get('/briefing-room/:category?', require('./briefing-room'));
router.get('/ostp', require('./ostp'));
};