feat: 增加财新网首页新闻、中国政府网滚动新闻、中国政府网新闻要闻 (#2533)

* 增加财新网首页新闻、中国政府网滚动新闻、中国政府网新闻要闻

* 增加财新网首页新闻、中国政府网滚动新闻、中国政府网新闻要闻的文档说明

* 整理格式

* 增加国务院信息

* 调整格式

* Remove User-Agent
This commit is contained in:
EsuRt
2019-07-04 16:25:17 +08:00
committed by DIYgod
parent 0fc49d7334
commit a424a95d06
7 changed files with 213 additions and 0 deletions

View File

@@ -20,6 +20,18 @@ pageClass: routes
<Route author="ciaranchen" example="/gov/zhengce/wenjian" path="/gov/zhengce/wenjian/:pcodeJiguan?" :paramsDesc="['文种分类。 国令; 国发; 国函; 国发明电; 国办发; 国办函; 国办发明电; 其他']" /> <Route author="ciaranchen" example="/gov/zhengce/wenjian" path="/gov/zhengce/wenjian/:pcodeJiguan?" :paramsDesc="['文种分类。 国令; 国发; 国函; 国发明电; 国办发; 国办函; 国办发明电; 其他']" />
### 滚动新闻
<Route author="EsuRt" example="/gov/xinwen/gundong" path="/gov/xinwen/gundong"/>
### 新闻要闻
<Route author="EsuRt" example="/gov/xinwen/yaowen" path="/gov/xinwen/yaowen"/>
### 国务院信息
<Route author="EsuRt" example="/gov/statecouncil/news" path="/gov/statecouncil/news"/>
### 江苏省人民政府 ### 江苏省人民政府
<Route author="ocleo1" example="/gov/province/jiangsu/important-news" path="/gov/province/jiangsu/:category" :paramsDesc="['分类名']"> <Route author="ocleo1" example="/gov/province/jiangsu/important-news" path="/gov/province/jiangsu/:category" :paramsDesc="['分类名']">

View File

@@ -120,6 +120,10 @@ Category 列表:
</Route> </Route>
### 首页新闻
<Route author="EsuRt" example="/caixin/article" path="/caixin/article"/>
## 东方网 ## 东方网
### 上海新闻 ### 上海新闻

View File

@@ -328,6 +328,8 @@ router.get('/cctv/:category', require('./routes/cctv/category'));
router.get('/caixin/blog/:column', require('./routes/caixin/blog')); router.get('/caixin/blog/:column', require('./routes/caixin/blog'));
// 财新 // 财新
router.get('/caixin/:column/:category', require('./routes/caixin/category')); router.get('/caixin/:column/:category', require('./routes/caixin/category'));
//财新首页
router.get('/caixin/article', require('./routes/caixin/article'));
// 草榴社区 // 草榴社区
router.get('/t66y/post/:tid', require('./routes/t66y/post')); router.get('/t66y/post/:tid', require('./routes/t66y/post'));
@@ -1006,6 +1008,9 @@ router.get('/gov/zhengce/zuixin', require('./routes/gov/zhengce/zuixin'));
router.get('/gov/zhengce/wenjian/:pcodeJiguan?', require('./routes/gov/zhengce/wenjian')); router.get('/gov/zhengce/wenjian/:pcodeJiguan?', require('./routes/gov/zhengce/wenjian'));
router.get('/gov/province/:name/:category', require('./routes/gov/province')); router.get('/gov/province/:name/:category', require('./routes/gov/province'));
router.get('/gov/city/:name/:category', require('./routes/gov/city')); router.get('/gov/city/:name/:category', require('./routes/gov/city'));
router.get('/gov/xinwen/gundong', require('./routes/gov/xinwen/gundong'));
router.get('/gov/xinwen/yaowen', require('./routes/gov/xinwen/yaowen'));
router.get('/gov/statecouncil/news', require('./routes/gov/statecouncil/news'));
// 中华人民共和国生态环境部 // 中华人民共和国生态环境部
router.get('/gov/mee/gs', require('./routes/gov/mee/gs')); router.get('/gov/mee/gs', require('./routes/gov/mee/gs'));

View File

@@ -0,0 +1,27 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'http://mapiv5.caixin.com//m/api/getWapIndexListByPage?page=1&callback=jQuery213030389065931348935_1560140003113&_=1560140003179',
headers: {
Referer: `http://mapiv5.caixin.com/`,
Host: 'mapiv5.caixin.com',
},
});
const reg = /(.*jQuery.*\()([\s\S]*)(\))/;
const datatmp = response.data.replace(reg, '$2');
const data = JSON.parse(datatmp).data.list;
ctx.state.data = {
title: `财新网 - 首页`,
link: `http://www.caixin.com/`,
description: '财新网 - 首页',
item: data.map((item) => ({
title: item.title,
description: item.summary,
link: item.web_url,
})),
};
};

View File

@@ -0,0 +1,55 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const link = `http://www.gov.cn/pushinfo/v150203/`;
const listData = await got.get(link);
const $list = cheerio.load(listData.data);
ctx.state.data = {
title: '中国政府网 - 国务院信息',
link,
item: await Promise.all(
$list('.news_box .list li:not(.line)')
.slice(1, 12)
.map(async (_, el) => {
const $el = $list(el);
const $a = $el.find('h4 a');
const href = $a.attr('href');
const key = `gov_statecouncil: ${href}`;
let description;
let dataEncode;
let dataDecode;
let urlSplit;
const value = await ctx.cache.get(key);
if (value) {
description = value;
} else {
const contentUrl = href.startsWith('/') ? `http://www.gov.cn${href}` : href;
const contentData = await got.get(contentUrl);
const $content = cheerio.load(contentData.data);
const regImg = /(img src=")(.*)(".*)/g;
const regUrl = /(http.*\/)(content.*)/;
if (contentData.data.indexOf('UCAP-CONTENT') !== -1) {
dataEncode = $content('#UCAP-CONTENT').html();
} else {
dataEncode = $content('body').html();
}
dataDecode = unescape(dataEncode.replace(/&#x/g, '%u').replace(/;/g, ''));
urlSplit = contentUrl.replace(regUrl, '$1');
description = dataDecode.replace(regImg, '$1' + urlSplit + '$2' + '$3');
ctx.cache.set(key, description);
}
return {
title: $a.text(),
description,
link: $a.attr('href'),
pubDate: new Date($el.find('.date').text()).toUTCString(),
};
})
.get()
),
};
};

View File

@@ -0,0 +1,55 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const link = `http://www.gov.cn/xinwen/gundong.htm`;
const listData = await got.get(link);
const $list = cheerio.load(listData.data);
ctx.state.data = {
title: '中国政府网 - 滚动新闻',
link,
item: await Promise.all(
$list('.news_box .list li:not(.line)')
.slice(1, 12)
.map(async (_, el) => {
const $el = $list(el);
const $a = $el.find('h4 a');
const href = $a.attr('href');
const key = `gov_gundong: ${href}`;
let description;
let dataEncode;
let dataDecode;
let urlSplit;
const value = await ctx.cache.get(key);
if (value) {
description = value;
} else {
const contentUrl = href.startsWith('/') ? `http://www.gov.cn${href}` : href;
const contentData = await got.get(contentUrl);
const $content = cheerio.load(contentData.data);
const regImg = /(img src=")(.*)(".*)/g;
const regUrl = /(http.*\/)(content.*)/;
if (contentData.data.indexOf('UCAP-CONTENT') !== -1) {
dataEncode = $content('#UCAP-CONTENT').html();
} else {
dataEncode = $content('body').html();
}
dataDecode = unescape(dataEncode.replace(/&#x/g, '%u').replace(/;/g, ''));
urlSplit = contentUrl.replace(regUrl, '$1');
description = dataDecode.replace(regImg, '$1' + urlSplit + '$2' + '$3');
ctx.cache.set(key, description);
}
return {
title: $a.text(),
description,
link: $a.attr('href'),
pubDate: new Date($el.find('.date').text()).toUTCString(),
};
})
.get()
),
};
};

View File

@@ -0,0 +1,55 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const link = `http://www.gov.cn/xinwen/yaowen.htm`;
const listData = await got.get(link);
const $list = cheerio.load(listData.data);
ctx.state.data = {
title: '中国政府网 - 要闻',
link,
item: await Promise.all(
$list('.news_box .list li:not(.line)')
.slice(1, 12)
.map(async (_, el) => {
const $el = $list(el);
const $a = $el.find('h4 a');
const href = $a.attr('href');
const key = `gov_yaowen: ${href}`;
let description;
let dataEncode;
let dataDecode;
let urlSplit;
const value = await ctx.cache.get(key);
if (value) {
description = value;
} else {
const contentUrl = href.startsWith('/') ? `http://www.gov.cn${href}` : href;
const contentData = await got.get(contentUrl);
const $content = cheerio.load(contentData.data);
const regImg = /(img src=")(.*)(".*)/g;
const regUrl = /(http.*\/)(content.*)/;
if (contentData.data.indexOf('UCAP-CONTENT') !== -1) {
dataEncode = $content('#UCAP-CONTENT').html();
} else {
dataEncode = $content('body').html();
}
dataDecode = unescape(dataEncode.replace(/&#x/g, '%u').replace(/;/g, ''));
urlSplit = contentUrl.replace(regUrl, '$1');
description = dataDecode.replace(regImg, '$1' + urlSplit + '$2' + '$3');
ctx.cache.set(key, description);
}
return {
title: $a.text(),
description,
link: $a.attr('href'),
pubDate: new Date($el.find('.date').text()).toUTCString(),
};
})
.get()
),
};
};