diff --git a/docs/en/new-media.md b/docs/en/new-media.md index f06929a60..79f534704 100644 --- a/docs/en/new-media.md +++ b/docs/en/new-media.md @@ -41,6 +41,12 @@ Compared to the official one, the RSS feed generated by RSSHub not only has more +## American Federation of Labor and Congress of Industrial Organizations + +### Blog + + + ## Bell Labs ### Event and News diff --git a/docs/new-media.md b/docs/new-media.md index 4edde1593..43952076c 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1522,6 +1522,12 @@ column 为 third 时可选的 category: +## 美国劳工联合会 - 产业工会联合会 + +### 博客 + + + ## 梅花网 ### 作品 diff --git a/lib/router.js b/lib/router.js index dbf0677a4..62b2ee020 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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; diff --git a/lib/routes/aflcio/blog.js b/lib/routes/aflcio/blog.js new file mode 100644 index 000000000..68001e214 --- /dev/null +++ b/lib/routes/aflcio/blog.js @@ -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, + }; +};