diff --git a/docs/en/new-media.md b/docs/en/new-media.md index e32a195702..21344b1b20 100644 --- a/docs/en/new-media.md +++ b/docs/en/new-media.md @@ -260,3 +260,15 @@ Provides a better reading experience (full text articles) over the official one. ### Newsroom + +## China Labour Watch + +### Reports + + + +| All | Automotive | Cookware | Electronics | Footwear | Furniture | Garment | General | Printing | Retail | Toys | +| - | - | - | - | - | - | - | - | - | - | - | +| | 2 | 6 | 14 | 3 | 4 | 10 | 8 | 1 | 9 | 7 | + + \ No newline at end of file diff --git a/docs/new-media.md b/docs/new-media.md index 156a10aa2b..5a68e9da9d 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1897,6 +1897,18 @@ QueryString: +## 中国劳工观察 + +### 调查报告 + + + +| 全部 | 制鞋 | 印刷 | 厨具 | 家具 | 服饰 | 汽车制造 | 玩具 | 电子产品 | 综合 | 零售 | +| ---- | ---- | ---- | ---- | ---- | ---- | -------- | ---- | -------- | ---- | ---- | +| | 2 | 6 | 14 | 3 | 4 | 10 | 8 | 1 | 9 | 7 | + + + ## 中国劳工通讯 ### 评论与特写 diff --git a/lib/router.js b/lib/router.js index 3dd14a82d4..b04800a7c8 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3519,6 +3519,9 @@ router.get('/uisdc/news', require('./routes/uisdc/news')); router.get('/uisdc/zt/:title?', require('./routes/uisdc/zt')); router.get('/uisdc/topic/:title?/:sort?', require('./routes/uisdc/topic')); +// 中国劳工观察 +router.get('/chinalaborwatch/reports/:lang?/:industry?', require('./routes/chinalaborwatch/reports')); + // 美国中央情报局 router.get('/cia/foia-annual-report', require('./routes/us/cia/foia-annual-report')); diff --git a/lib/routes/chinalaborwatch/reports.js b/lib/routes/chinalaborwatch/reports.js new file mode 100644 index 0000000000..2e38b53a41 --- /dev/null +++ b/lib/routes/chinalaborwatch/reports.js @@ -0,0 +1,54 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const lang = ctx.params.lang || ''; + const industry = ctx.params.industry || ''; + + const rootUrl = 'http://www.chinalaborwatch.org'; + const currentUrl = `${rootUrl}/${lang === '' ? '' : 'cn/'}reports${industry === '' ? '' : `/industry/${industry}`}`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + const $ = cheerio.load(response.data); + + const list = $('.Alt1 a, .Alt2 a') + .slice(0, 10) + .map((_, item) => { + item = $(item); + return { + title: item.text(), + link: `${rootUrl}${item.attr('href')}`, + }; + }) + .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.pubDate = new Date(content('#ContentPlaceHolder1_LabelDate').text().replace(/年|月/g, '-').replace('日', '')).toUTCString(); + + content('h1, #ContentPlaceHolder1_LabelDate').remove(); + + item.description = content('.mainContent').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `${$('title').text()} - ${lang === '' ? 'China Labour Watch' : '中国劳工观察'}`, + link: currentUrl, + item: items, + }; +};