feat: add 教育部阳光高考信息公开平台招生政策规定

This commit is contained in:
nczitzk
2021-01-10 21:09:18 +08:00
parent b1ae777b87
commit 5b3b7ee172
3 changed files with 67 additions and 0 deletions
+12
View File
@@ -388,6 +388,18 @@ pageClass: routes
</Route>
## 阳光高考
### 教育部阳光高考信息公开平台招生政策规定
<Route author="nczitzk" example="/chsi/zszcgd" path="/chsi/zszcgd/:category?" :paramsDesc="['分类,默认为招生政策']">
| 招生政策 | 深化考试招生制度改革 | 教育法律法规 |
| -------- | -------------------- | ------------ |
| dnzszc | zdgg | jyflfg |
</Route>
## 印象识堂
### 印象剪藏
+3
View File
@@ -3780,4 +3780,7 @@ router.get('/nace/blog/:sort?', require('./routes/nace/blog'));
// Caixin Latest
router.get('/caixin/latest', require('./routes/caixin/latest'));
// 阳光高考
router.get('/chsi/zszcgd/:category?', require('./routes/chsi/zszcgd'));
module.exports = router;
+52
View File
@@ -0,0 +1,52 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const category = ctx.params.category || 'dnzszc';
const rootUrl = 'https://gaokao.chsi.com.cn';
const currentUrl = `${rootUrl}/gkxx/zszcgd/${category}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const list = $('.list ul li a')
.slice(0, 15)
.map((_, item) => {
item = $(item);
const link = item.attr('href');
return {
title: item.text(),
pubDate: new Date(item.prev().text()).toUTCString(),
link: link.indexOf('http') < 0 ? `${rootUrl}${link}` : link,
};
})
.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('.list').html();
return item;
})
)
);
ctx.state.data = {
title: `${$('.backb').text()} - 教育部阳光高考信息公开平台`,
link: currentUrl,
item: items,
};
};