feat: add 泉州市跨境电子商务协会 (#5691)

Co-authored-by: Henry Wang <hi@henry.wang>
This commit is contained in:
Ethan Shen
2020-09-20 21:40:00 +01:00
committed by GitHub
co-authored by Henry Wang
parent 9fb13f3147
commit 186c78e7cd
3 changed files with 67 additions and 0 deletions
+12
View File
@@ -71,6 +71,18 @@ pageClass: routes
<Route author="HenryQW" example="/un/scveto" path="/un/scveto"/>
## 泉州市跨境电子商务协会
### 新闻动态
<Route author="nczitzk" example="/qzcea" path="/qzcea/:caty?" :paramsDesc="['分类 id,默认为 1']">
| 新闻动态 | 协会动态 | 通知公告 | 会员风采 | 政策法规 | 电商资讯 |
| -------- | -------- | -------- | -------- | -------- | -------- |
| 1 | 2 | 3 | 5 | 14 | 18 |
</Route>
## 日本国外務省
### 記者会見
+3
View File
@@ -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'));
+52
View File
@@ -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,
};
};