diff --git a/docs/study.md b/docs/study.md index 6080dd0ed..7d94b743d 100644 --- a/docs/study.md +++ b/docs/study.md @@ -538,3 +538,59 @@ path="/ctfhub/upcoming/:limit?" ### 通知公告 + +## 中国智库网 + +### 观点与实践 + + + +| `:id` | 专题名称 | +| ----- | -------- | +| 2 | 党的建设 | +| 3 | 社会 | +| 4 | 生态 | +| 5 | 政治 | +| 6 | 经济 | +| 7 | 文化 | +| 9 | 热点专题 | +| 10 | 国际关系 | +| 13 | 国外智库 | +| 46 | 智库报告 | +| 57 | 智库要闻 | +| 126 | 世界经济 | +| 127 | 宏观经济 | +| 128 | 区域经济 | +| 129 | 产业企业 | +| 130 | 三农问题 | +| 131 | 财政金融 | +| 132 | 科技创新 | +| 133 | 民主 | +| 134 | 法治 | +| 135 | 行政 | +| 136 | 国家治理 | +| 137 | 社会事业 | +| 138 | 社会保障 | +| 139 | 民族宗教 | +| 140 | 人口就业 | +| 141 | 社会治理 | +| 142 | 文化产业 | +| 143 | 公共文化 | +| 144 | 文化体制 | +| 145 | 文化思想 | +| 146 | 资源 | +| 147 | 能源 | +| 148 | 环境 | +| 149 | 生态文明 | +| 150 | 思想建设 | +| 151 | 作风建设 | +| 152 | 组织建设 | +| 153 | 制度建设 | +| 154 | 反腐倡廉 | +| 155 | 中国外交 | +| 156 | 全球治理 | +| 157 | 大国关系 | +| 158 | 地区政治 | +| 181 | 执政能力 | + + diff --git a/lib/v2/chinathinktanks/maintainer.js b/lib/v2/chinathinktanks/maintainer.js new file mode 100644 index 000000000..fad146a60 --- /dev/null +++ b/lib/v2/chinathinktanks/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:id': ['Aeliu'], +}; diff --git a/lib/v2/chinathinktanks/radar.js b/lib/v2/chinathinktanks/radar.js new file mode 100644 index 000000000..28f5a4e8f --- /dev/null +++ b/lib/v2/chinathinktanks/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'chinathinktanks.org.cn': { + _name: '中国智库网', + www: [ + { + title: '观点与实践', + docs: 'https://docs.rsshub.app/study.html#zhong-guo-zhi-ku-wang', + source: '', + target: (params, url) => `/chinathinktanks/${new URL(url).searchParams.get('id')}`, + }, + ], + }, +}; diff --git a/lib/v2/chinathinktanks/router.js b/lib/v2/chinathinktanks/router.js new file mode 100644 index 000000000..c628103b9 --- /dev/null +++ b/lib/v2/chinathinktanks/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:id', require('./viewpoint')); +}; diff --git a/lib/v2/chinathinktanks/viewpoint.js b/lib/v2/chinathinktanks/viewpoint.js new file mode 100644 index 000000000..089fb7358 --- /dev/null +++ b/lib/v2/chinathinktanks/viewpoint.js @@ -0,0 +1,53 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate, parseRelativeDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); +const { CookieJar } = require('tough-cookie'); + +const cookieJar = new CookieJar(); +const baseUrl = 'https://www.chinathinktanks.org.cn'; + +module.exports = async (ctx) => { + const link = `https://www.chinathinktanks.org.cn/content/list?id=${ctx.params.id}&pt=1`; + + const response = await got(link, { + cookieJar, + }); + const $ = cheerio.load(response.data); + + let items = $('.main-content-left-list-item') + .toArray() + .map((e) => { + e = $(e); + return { + title: e.find('.title span').text(), + link: baseUrl + e.attr('href'), + author: e.find('.author-by span').text(), + pubDate: e.find('.author-time').text(), + }; + }); + + items = await Promise.all( + items.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const response = await got({ + url: item.link, + cookieJar, + }); + const $ = cheerio.load(response.data); + const content = $('#art'); + item.description = content.html(); + item.pubDate = item.pubDate.includes('-') ? timezone(parseDate(item.pubDate, 'YYYY-MM-DD'), +8) : parseRelativeDate(item.pubDate); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `中国智库网 —— ${$('title').text().split('_中国智库网')[0]}`, + link, + item: items, + }; +};