diff --git a/docs/other.md b/docs/other.md index 47030a9b99..c674113c73 100644 --- a/docs/other.md +++ b/docs/other.md @@ -799,6 +799,20 @@ type 为 all 时,category 参数不支持 cost 和 free +## 天津产权交易中心 + +### 产权转让 + + + +### 企业资产转让 + + + +### 新闻动态 + + + ## 推酷 ### 周刊 diff --git a/lib/router.js b/lib/router.js index 85c0f9af87..833a29feb1 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1456,4 +1456,9 @@ router.get('/lolapp/recommend', require('./routes/lolapp/recommend')); // 左岸读书 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; diff --git a/lib/routes/tprtc/cqzr.js b/lib/routes/tprtc/cqzr.js new file mode 100644 index 0000000000..49da1e5f9f --- /dev/null +++ b/lib/routes/tprtc/cqzr.js @@ -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 = ` + `; + + // 提取内容 + 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, + }; +}; diff --git a/lib/routes/tprtc/news.js b/lib/routes/tprtc/news.js new file mode 100644 index 0000000000..c6e100ce1a --- /dev/null +++ b/lib/routes/tprtc/news.js @@ -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, + }; +}; diff --git a/lib/routes/tprtc/qyzc.js b/lib/routes/tprtc/qyzc.js new file mode 100644 index 0000000000..a8ccad5745 --- /dev/null +++ b/lib/routes/tprtc/qyzc.js @@ -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 = ` + `; + + // 提取内容 + 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, + }; +};