feat: add 美国劳工联合会-产业工会联合会博客 (#6906)
This commit is contained in:
@@ -41,6 +41,12 @@ Compared to the official one, the RSS feed generated by RSSHub not only has more
|
||||
|
||||
<RouteEn author="nczitzk" example="/asml/press-releases" path="/asml/press-releases"/>
|
||||
|
||||
## American Federation of Labor and Congress of Industrial Organizations
|
||||
|
||||
### Blog
|
||||
|
||||
<RouteEn author="nczitzk" example="/aflcio/blog" path="/aflcio/blog"/>
|
||||
|
||||
## Bell Labs
|
||||
|
||||
### Event and News
|
||||
|
||||
@@ -1522,6 +1522,12 @@ column 为 third 时可选的 category:
|
||||
|
||||
</Route>
|
||||
|
||||
## 美国劳工联合会 - 产业工会联合会
|
||||
|
||||
### 博客
|
||||
|
||||
<Route author="nczitzk" example="/aflcio/blog" path="/aflcio/blog"/>
|
||||
|
||||
## 梅花网
|
||||
|
||||
### 作品
|
||||
|
||||
@@ -3927,4 +3927,7 @@ router.get('/kenshin/:category?/:type?', require('./routes/kenshin/index'));
|
||||
router.get('/av01/actor/:name/:type?', require('./routes/av01/actor'));
|
||||
router.get('/av01/tag/:name/:type?', require('./routes/av01/tag'));
|
||||
|
||||
// 美国劳工联合会-产业工会联合会
|
||||
router.get('/aflcio/blog', require('./routes/aflcio/blog'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://aflcio.org';
|
||||
const currentUrl = `${rootUrl}/blog`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('article')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const title = item.find('h1 a');
|
||||
return {
|
||||
title: title.text(),
|
||||
link: `${rootUrl}${title.attr('href')}`,
|
||||
pubDate: new Date(item.find('time').attr('datetime')).toUTCString(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
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.description = content('.section-article-body').html();
|
||||
item.author = detailResponse.data.match(/entityName":"(.*)","entityType"/)[1];
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user