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:
parent
6a4b939509
commit
ba9891f578
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -240,6 +240,10 @@ pageClass: routes
|
|||
|
||||
</Route>
|
||||
|
||||
### 科学技术政策办公室
|
||||
|
||||
<Route author="LyleLee" example="/whitehouse/ostp" path="/whitehouse/ostp"/>
|
||||
|
||||
## 美国财政部
|
||||
|
||||
### 新闻稿
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
module.exports = {
|
||||
'/briefing-room/:category?': ['nczitzk'],
|
||||
'/ostp': ['LyleLee'],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
@ -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',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/briefing-room/:category?', require('./briefing-room'));
|
||||
router.get('/ostp', require('./ostp'));
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue