diff --git a/docs/government.md b/docs/government.md index e9f44990e..8444dffb2 100644 --- a/docs/government.md +++ b/docs/government.md @@ -198,14 +198,14 @@ pageClass: routes -## 中央纪委国家监委 - -### 审查调查 - - - ## 中华人民共和国外交部 ### 发言人表态 + +## 中央纪委国家监委 + +### 审查调查 + + diff --git a/lib/routes/tprtc/cqzr.js b/lib/routes/tprtc/cqzr.js index 49da1e5f9..9ade0ea0d 100644 --- a/lib/routes/tprtc/cqzr.js +++ b/lib/routes/tprtc/cqzr.js @@ -3,12 +3,14 @@ const cheerio = require('cheerio'); const url = require('url'); module.exports = async (ctx) => { + const pagelink = 'http://otc.tprtc.com/tjcqp/cgq/search/index'; + const host = 'http://otc.tprtc.com'; + 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=', + url: 'http://otc.tprtc.com/tjcqp/cgq/search/search_li', 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', + Referer: pagelink, 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', }, @@ -24,8 +26,7 @@ module.exports = async (ctx) => { 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', + Referer: pagelink, 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', }, @@ -36,8 +37,8 @@ module.exports = async (ctx) => { $('.bd_detail_main .bd_detail_tab').remove(); // 文章样式 - const style = ` - `; + const style = ` + `; // 提取内容 const description = $('.bd_detail_main').html() + style; @@ -45,7 +46,6 @@ module.exports = async (ctx) => { return description; }; - const host = 'http://item.tprtc.com'; const items = await Promise.all( list.map(async (item) => { const $ = cheerio.load(item); @@ -73,7 +73,7 @@ module.exports = async (ctx) => { ctx.state.data = { title: '产权转让-天津产权交易中心', - link: 'http://item.tprtc.com/tjcqp/cgq/search/index?plfs=2', + link: pagelink, description: '天津产权交易中心-产权转让', item: items, }; diff --git a/lib/routes/tprtc/news.js b/lib/routes/tprtc/news.js index c6e100ce1..bfbea2ad0 100644 --- a/lib/routes/tprtc/news.js +++ b/lib/routes/tprtc/news.js @@ -1,13 +1,16 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const url = require('url'); module.exports = async (ctx) => { + const pagelink = 'http://www.tprtc.com/page/channel/news?id=89'; + const host = 'http://www.tprtc.com'; + const response = await got({ method: 'get', - url: 'http://www.tprtc.com/InformationChannel/index.jhtml', + url: pagelink, 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', }, @@ -16,21 +19,29 @@ module.exports = async (ctx) => { const data = response.data; const $ = cheerio.load(data); - const list = $('.c1-bline').get(); + const list = $('.news_list li').get(); const ProcessFeed = async (link) => { - const response = await got.get(link); + const response = await got({ + method: 'get', + url: link, + headers: { + Referer: pagelink, + 'Accept-Encoding': 'gzip, deflate', + 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', + }, + }); const $ = cheerio.load(response.data); - return $('.content').html(); + return $('.new_detail_cont').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 $title = $('a'); + const itemUrl = url.resolve(host, $title.attr('href')); const cache = await ctx.cache.get(itemUrl); if (cache) { @@ -40,10 +51,10 @@ module.exports = async (ctx) => { const description = await ProcessFeed(itemUrl); const single = { - title: $('a.red').text() + ' ' + $title.attr('title'), + title: $title.attr('title'), link: itemUrl, description, - author: $('a.red').text(), + pubDate: new Date($('.news_time').text()).toUTCString(), }; ctx.cache.set(itemUrl, JSON.stringify(single)); @@ -53,7 +64,7 @@ module.exports = async (ctx) => { ctx.state.data = { title: '新闻动态-天津产权交易中心', - link: 'http://www.tprtc.com/InformationChannel/index.jhtml', + link: pagelink, description: '天津产权交易中心-新闻动态', item: items, }; diff --git a/lib/routes/tprtc/qyzc.js b/lib/routes/tprtc/qyzc.js index a8ccad574..f89eef7ac 100644 --- a/lib/routes/tprtc/qyzc.js +++ b/lib/routes/tprtc/qyzc.js @@ -3,12 +3,14 @@ const cheerio = require('cheerio'); const url = require('url'); module.exports = async (ctx) => { + const pagelink = 'http://otc.tprtc.com/tjcqp/s/jyzx/qyzc'; + const host = 'http://otc.tprtc.com'; + 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=', + url: 'http://otc.tprtc.com/tjcqp/s/jyzx/qyzc_li', 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', + Referer: pagelink, 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', }, @@ -24,8 +26,7 @@ module.exports = async (ctx) => { 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', + Referer: pagelink, 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', }, @@ -39,8 +40,8 @@ module.exports = async (ctx) => { $('.bd_detail_left [id^="clob_formweb_value_"]').remove(); // 文章样式 - const style = ` - `; + const style = ` + `; // 提取内容 const description = $('.bd_detail_left').html() + style; @@ -48,7 +49,6 @@ module.exports = async (ctx) => { return description; }; - const host = 'http://item.tprtc.com'; const items = await Promise.all( list.map(async (item) => { const $ = cheerio.load(item); @@ -77,7 +77,7 @@ module.exports = async (ctx) => { ctx.state.data = { title: '企业资产转让-天津产权交易中心', - link: 'http://item.tprtc.com/tjcqp/s/jyzx/qyzc', + link: pagelink, description: '天津产权交易中心-企业资产转让', item: items, };