feat: add tprtc (#2528)

* feat: add tprtc

* feat: add tprtc

* feat: add tprtc

* Update other.md

* limit 20

* limit 20
This commit is contained in:
Cloud
2019-07-02 11:19:23 +08:00
committed by DIYgod
parent 68dd8c570a
commit 030f0fb83e
5 changed files with 243 additions and 0 deletions

View File

@@ -799,6 +799,20 @@ type 为 all 时category 参数不支持 cost 和 free
<Route author="Qixingchen" example="/tucaoqq/post/28564/CdRI0728" path="/tucaoqq/post/:project/:key" :paramsDesc="['产品 ID', '产品密钥']"/> <Route author="Qixingchen" example="/tucaoqq/post/28564/CdRI0728" path="/tucaoqq/post/:project/:key" :paramsDesc="['产品 ID', '产品密钥']"/>
## 天津产权交易中心
### 产权转让
<Route author="kt286" example="/tprtc/cqzr" path="/tprtc/cqzr"/>
### 企业资产转让
<Route author="kt286" example="/tprtc/qyzc" path="/tprtc/qyzc"/>
### 新闻动态
<Route author="kt286" example="/tprtc/news" path="/tprtc/news"/>
## 推酷 ## 推酷
### 周刊 ### 周刊

View File

@@ -1456,4 +1456,9 @@ router.get('/lolapp/recommend', require('./routes/lolapp/recommend'));
// 左岸读书 // 左岸读书
router.get('/zreading', require('./routes/zreading/home')); router.get('/zreading', require('./routes/zreading/home'));
// 天津产权交易中心
router.get('/tprtc/cqzr', require('./routes/tprtc/cqzr'));
router.get('/tprtc/qyzc', require('./routes/tprtc/qyzc'));
router.get('/tprtc/news', require('./routes/tprtc/news'));
module.exports = router; module.exports = router;

80
lib/routes/tprtc/cqzr.js Normal file
View File

@@ -0,0 +1,80 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const url = require('url');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'http://item.tprtc.com/tjcqp/cgq/search/search_li?xxplfs=&zrdj=0&nzrbl=0&hy=&szdq=&sortTag=0&pageNo=1&pageSize=20&keyWord=',
headers: {
Referer: 'http://item.tprtc.com/tjcqp/cgq/search/index?plfs=2',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3793.0 Safari/537.36',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
},
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('li').get();
const ProcessFeed = async (link) => {
const response = await got({
method: 'get',
url: link,
headers: {
Referer: 'http://item.tprtc.com/tjcqp/cgq/search/index?plfs=2',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3793.0 Safari/537.36',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
},
});
const $ = cheerio.load(response.data);
// 删除没用的tab指示
$('.bd_detail_main .bd_detail_tab').remove();
// 文章样式
const style = `<link rel="stylesheet" href="http://item.tprtc.com/res/prj/tjcq/css/notheme/notheme_all_min.css" type="text/css">
<link rel="stylesheet" href="http://item.tprtc.com/res/prj/tjcq/css/themes/default/common_all_min.css" type="text/css"/>`;
// 提取内容
const description = $('.bd_detail_main').html() + style;
return description;
};
const host = 'http://item.tprtc.com';
const items = await Promise.all(
list.map(async (item) => {
const $ = cheerio.load(item);
const $title = $('.property_list_title>a');
const itemUrl = url.resolve(host, $title.attr('href'));
const cache = await ctx.cache.get(itemUrl);
if (cache) {
return Promise.resolve(JSON.parse(cache));
}
const description = await ProcessFeed(itemUrl);
const single = {
title: $('.property_list_title>span').text() + ' ' + $title.text(),
link: itemUrl,
description,
};
ctx.cache.set(itemUrl, JSON.stringify(single));
return Promise.resolve(single);
})
);
ctx.state.data = {
title: '产权转让-天津产权交易中心',
link: 'http://item.tprtc.com/tjcqp/cgq/search/index?plfs=2',
description: '天津产权交易中心-产权转让',
item: items,
};
};

60
lib/routes/tprtc/news.js Normal file
View File

@@ -0,0 +1,60 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'http://www.tprtc.com/InformationChannel/index.jhtml',
headers: {
Referer: 'http://www.tprtc.com',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3793.0 Safari/537.36',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
},
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('.c1-bline').get();
const ProcessFeed = async (link) => {
const response = await got.get(link);
const $ = cheerio.load(response.data);
return $('.content').html();
};
const items = await Promise.all(
list.map(async (item) => {
const $ = cheerio.load(item);
const $title = $('.f-left>a:last-child');
const itemUrl = $title.attr('href');
const cache = await ctx.cache.get(itemUrl);
if (cache) {
return Promise.resolve(JSON.parse(cache));
}
const description = await ProcessFeed(itemUrl);
const single = {
title: $('a.red').text() + ' ' + $title.attr('title'),
link: itemUrl,
description,
author: $('a.red').text(),
};
ctx.cache.set(itemUrl, JSON.stringify(single));
return Promise.resolve(single);
})
);
ctx.state.data = {
title: '新闻动态-天津产权交易中心',
link: 'http://www.tprtc.com/InformationChannel/index.jhtml',
description: '天津产权交易中心-新闻动态',
item: items,
};
};

84
lib/routes/tprtc/qyzc.js Normal file
View File

@@ -0,0 +1,84 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const url = require('url');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'http://item.tprtc.com/tjcqp/s/jyzx/qyzc_li?plfs=&gpjg=&szdq=&sortTag=0&pageSize=20&pageNo=1&keyWord=',
headers: {
Referer: 'http://item.tprtc.com/tjcqp/s/jyzx/qyzc',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3793.0 Safari/537.36',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
},
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('li').get();
const ProcessFeed = async (link) => {
const response = await got({
method: 'get',
url: link,
headers: {
Referer: 'http://item.tprtc.com/tjcqp/s/jyzx/qyzc',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3793.0 Safari/537.36',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
},
});
const $ = cheerio.load(response.data);
// 删除没用的tab指示
$('.bd_detail_left .bd_detail_scroll').remove();
$('.bd_detail_left .property_tab').remove();
$('.bd_detail_left .bd_detail_follow').remove();
$('.bd_detail_left [id^="clob_formweb_value_"]').remove();
// 文章样式
const style = `<link rel="stylesheet" href="http://item.tprtc.com/res/prj/tjcq/css/notheme/notheme_all_min.css" type="text/css">
<link rel="stylesheet" href="http://item.tprtc.com/res/prj/tjcq/css/themes/default/common_all_min.css" type="text/css"/>`;
// 提取内容
const description = $('.bd_detail_left').html() + style;
return description;
};
const host = 'http://item.tprtc.com';
const items = await Promise.all(
list.map(async (item) => {
const $ = cheerio.load(item);
const $title = $('.bdlist_title>a');
const itemUrl = url.resolve(host, $title.attr('href'));
const cache = await ctx.cache.get(itemUrl);
if (cache) {
return Promise.resolve(JSON.parse(cache));
}
const description = await ProcessFeed(itemUrl);
const single = {
title: $title.text(),
link: itemUrl,
description,
author: $('.bdlist_time').text(),
};
ctx.cache.set(itemUrl, JSON.stringify(single));
return Promise.resolve(single);
})
);
ctx.state.data = {
title: '企业资产转让-天津产权交易中心',
link: 'http://item.tprtc.com/tjcqp/s/jyzx/qyzc',
description: '天津产权交易中心-企业资产转让',
item: items,
};
};