feat: add 中国庭审公开网 (#6781)

This commit is contained in:
Fatpandac
2021-01-25 16:00:26 -05:00
committed by GitHub
parent 5ea6a49754
commit ad88d2dc4b
3 changed files with 37 additions and 0 deletions
+6
View File
@@ -217,6 +217,12 @@ pageClass: routes
</Route>
## 中国庭审公开网
### 开庭信息
<Route author="Fatpandac" example="/tingshen" path="/tingshen"/>
## 中国信息通信研究院
### 白皮书
+3
View File
@@ -3894,4 +3894,7 @@ router.get('/dxy/vaccine/:province?/:city?/:location?', require('./routes/dxy/va
// Wtu
router.get('/wtu/:type', require('./routes/universities/wtu'));
// 中国庭审公开网
router.get('/tingshen', require('./routes/tingshen/tingshen'));
module.exports = router;
+28
View File
@@ -0,0 +1,28 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const url = require('url').resolve;
const host = 'http://tingshen.court.gov.cn/preview';
module.exports = async (ctx) => {
const response = await got.get(host);
const $ = cheerio.load(response.data);
const list = $('ul[class="_preview_ul"]').find('li');
ctx.state.data = {
title: '中国庭审公开',
link: host,
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item.find('a[class="ellipsis22"]').text(),
description: '开庭法院:' + item.find('span[class="show-col show-court-name"]').find('a[target="_blank"]').text() + '\n时间:' + item.find('span[class="show-col show-time"]').text(),
pubDate: new Date(item.find('span[class="pull-right nes-date"]').text()).toUTCString(),
link: url(host, item.find('a[class="ellipsis22"]').attr('href')),
};
})
.get(),
};
};