diff --git a/docs/government.md b/docs/government.md index 7ca063f443..206cd3aadd 100644 --- a/docs/government.md +++ b/docs/government.md @@ -71,6 +71,18 @@ pageClass: routes +## 泉州市跨境电子商务协会 + +### 新闻动态 + + + +| 新闻动态 | 协会动态 | 通知公告 | 会员风采 | 政策法规 | 电商资讯 | +| -------- | -------- | -------- | -------- | -------- | -------- | +| 1 | 2 | 3 | 5 | 14 | 18 | + + + ## 日本国外務省 ### 記者会見 diff --git a/lib/router.js b/lib/router.js index 64ed66efa4..aa68f1f37e 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3216,6 +3216,9 @@ router.get('/feixuew/:id?', require('./routes/feixuew/index')); // 1X router.get('/1x/:type?/:caty?', require('./routes/1x/index')); +// 泉州市跨境电子商务协会 +router.get('/qzcea/:caty?', require('./routes/qzcea/index')); + // 福利年 router.get('/fulinian/:caty?', require('./routes/fulinian/index')); diff --git a/lib/routes/qzcea/index.js b/lib/routes/qzcea/index.js new file mode 100644 index 0000000000..7d470fd727 --- /dev/null +++ b/lib/routes/qzcea/index.js @@ -0,0 +1,52 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + ctx.params.caty = ctx.params.caty || '1'; + + const rootUrl = 'http://www.qzcea.org'; + const currentUrl = `${rootUrl}/usernewscatname_nc${ctx.params.caty}`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + $('a.news-more').remove(); + + const list = $('li.clearfix div.news-right a') + .slice(0, 10) + .map((_, item) => { + item = $(item); + return { + title: item.text(), + link: `${rootUrl}${item.attr('href')}`, + pubDate: new Date(item.next().text().replace('时间 :', '') + ' GMT+8').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('div.newm').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `${$('title').text()} - 泉州市跨境电子商务协会`, + link: currentUrl, + item: items, + }; +};