From e6a54c29216e9d704d8a76e194ab5b70140b96a8 Mon Sep 17 00:00:00 2001
From: Ethan Shen <42264778+nczitzk@users.noreply.github.com>
Date: Tue, 19 Dec 2023 23:31:55 +0800
Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E4=B8=AD=E5=9B=BD?=
=?UTF-8?q?=E7=82=BC=E7=84=A6=E8=A1=8C=E4=B8=9A=E5=8D=8F=E4=BC=9A=20(#1407?=
=?UTF-8?q?4)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat(route): add 中国炼焦行业协会
* fix: remove subheadings for radar links
* fix typo
---
lib/v2/cnljxh/index.js | 71 +++++++++++++
lib/v2/cnljxh/maintainer.js | 7 ++
lib/v2/cnljxh/radar.js | 194 ++++++++++++++++++++++++++++++++++
lib/v2/cnljxh/router.js | 3 +
website/docs/routes/other.mdx | 78 ++++++++++++++
5 files changed, 353 insertions(+)
create mode 100644 lib/v2/cnljxh/index.js
create mode 100644 lib/v2/cnljxh/maintainer.js
create mode 100644 lib/v2/cnljxh/radar.js
create mode 100644 lib/v2/cnljxh/router.js
diff --git a/lib/v2/cnljxh/index.js b/lib/v2/cnljxh/index.js
new file mode 100644
index 000000000..2ead57914
--- /dev/null
+++ b/lib/v2/cnljxh/index.js
@@ -0,0 +1,71 @@
+const got = require('@/utils/got');
+const cheerio = require('cheerio');
+const { parseDate } = require('@/utils/parse-date');
+
+const defaultIds = {
+ collect: '10039',
+ date: '5575',
+ info: '575',
+ news: '10',
+ price: '299',
+};
+
+module.exports = async (ctx) => {
+ const { category = 'news', id = defaultIds.hasOwnProperty(category) ? defaultIds[category] : '10' } = ctx.params;
+ const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 10;
+
+ const rootUrl = 'http://www.cnljxh.com';
+ const currentUrl = new URL(`${category}/?classid=${id}`, rootUrl).href;
+
+ const { data: response } = await got(currentUrl);
+
+ const $ = cheerio.load(response);
+
+ let items = $('div.main_left ul li a')
+ .slice(0, limit)
+ .toArray()
+ .map((item) => {
+ item = $(item);
+
+ return {
+ title: item.prop('title') || item.text(),
+ link: new URL(item.prop('href'), currentUrl).href,
+ pubDate: parseDate(item.next().text()),
+ };
+ });
+
+ items = await Promise.all(
+ items.map((item) =>
+ ctx.cache.tryGet(item.link, async () => {
+ const { data: detailResponse } = await got(item.link);
+
+ const content = cheerio.load(detailResponse);
+
+ item.title = content('div.content_title h2').text() || item.title;
+ item.description = content('div.content_div').html();
+ item.enclosure_url = content('div.content_div embed').length === 0 ? undefined : new URL(content('div.content_div embed').prop('src'), currentUrl).href;
+ item.enclosure_type = item.enclosure_url ? `application/${item.enclosure_url.split(/\./).pop()}` : undefined;
+
+ return item;
+ })
+ )
+ );
+
+ const author = $('title').text();
+ const subtitle = $('div.mianbao').contents().last().text().split(/>/).pop().trim() || $('div.mianbao a').last().text();
+ const image = new URL($('div.logo a img').prop('src'), currentUrl).href;
+ const icon = new URL($('link[rel="shortcut icon"]').prop('href'), rootUrl).href;
+
+ ctx.state.data = {
+ item: items,
+ title: `${author} - ${subtitle}`,
+ link: currentUrl,
+ description: $('meta[name="description"]').prop('content'),
+ language: $('html').prop('lang'),
+ image,
+ icon,
+ logo: icon,
+ subtitle,
+ author,
+ };
+};
diff --git a/lib/v2/cnljxh/maintainer.js b/lib/v2/cnljxh/maintainer.js
new file mode 100644
index 000000000..8eeb0d4da
--- /dev/null
+++ b/lib/v2/cnljxh/maintainer.js
@@ -0,0 +1,7 @@
+module.exports = {
+ '/collect/:id?': ['nczitzk'],
+ '/date/:id?': ['nczitzk'],
+ '/info/:id?': ['nczitzk'],
+ '/news/:id?': ['nczitzk'],
+ '/price/:id?': ['nczitzk'],
+};
diff --git a/lib/v2/cnljxh/radar.js b/lib/v2/cnljxh/radar.js
new file mode 100644
index 000000000..62ac4411f
--- /dev/null
+++ b/lib/v2/cnljxh/radar.js
@@ -0,0 +1,194 @@
+module.exports = {
+ 'cnljxh.com': {
+ _name: '中国炼焦行业协会',
+ '.': [
+ {
+ title: '汇总',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-hui-zong',
+ source: ['/collect'],
+ target: (_, url) => {
+ url = new URL(url);
+ const id = url.searchParams.get('classid');
+
+ return `/cnljxh/collect${id ? `/${id}` : ''}`;
+ },
+ },
+ {
+ title: '价格指数',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-jia-ge-zhi-shu',
+ source: ['/date'],
+ target: (_, url) => {
+ url = new URL(url);
+ const id = url.searchParams.get('classid');
+
+ return `/cnljxh/date${id ? `/${id}` : ''}`;
+ },
+ },
+ {
+ title: '分析数据',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-fen-xi-shu-ju',
+ source: ['/info'],
+ target: (_, url) => {
+ url = new URL(url);
+ const id = url.searchParams.get('classid');
+
+ return `/cnljxh/info${id ? `/${id}` : ''}`;
+ },
+ },
+ {
+ title: '新闻',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen',
+ source: ['/news'],
+ target: (_, url) => {
+ url = new URL(url);
+ const id = url.searchParams.get('classid');
+
+ return `/cnljxh/news${id ? `/${id}` : ''}`;
+ },
+ },
+ {
+ title: '价格',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-jia-ge',
+ source: ['/price'],
+ target: (_, url) => {
+ url = new URL(url);
+ const id = url.searchParams.get('classid');
+
+ return `/cnljxh/price${id ? `/${id}` : ''}`;
+ },
+ },
+ {
+ title: '价格汇总',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-hui-zong',
+ source: ['/collect'],
+ target: '/cnljxh/collect/10039',
+ },
+ {
+ title: '焦炭指数',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-jia-ge-zhi-shu',
+ source: ['/date'],
+ target: '/cnljxh/date/5575',
+ },
+ {
+ title: '炼焦煤指数',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-jia-ge-zhi-shu',
+ source: ['/date'],
+ target: '/cnljxh/date/5907',
+ },
+ {
+ title: '市场分析',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-fen-xi-shu-ju',
+ source: ['/info'],
+ target: '/cnljxh/info/575',
+ },
+ {
+ title: '一周评述',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-fen-xi-shu-ju',
+ source: ['/info'],
+ target: '/cnljxh/info/5573',
+ },
+ {
+ title: '核心数据',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-fen-xi-shu-ju',
+ source: ['/info'],
+ target: '/cnljxh/info/5417',
+ },
+ {
+ title: '协会专区 - 协会简介',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen',
+ source: ['/news'],
+ target: '/cnljxh/news/24',
+ },
+ {
+ title: '协会专区 - 协会章程',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen',
+ source: ['/news'],
+ target: '/cnljxh/news/25',
+ },
+ {
+ title: '协会专区 - 协会领导',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen',
+ source: ['/news'],
+ target: '/cnljxh/news/26',
+ },
+ {
+ title: '协会专区 - 入会程序',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen',
+ source: ['/news'],
+ target: '/cnljxh/news/27',
+ },
+ {
+ title: '协会专区 - 组织机构',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen',
+ source: ['/news'],
+ target: '/cnljxh/news/28',
+ },
+ {
+ title: '协会公告',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen',
+ source: ['/news'],
+ target: '/cnljxh/news/10',
+ },
+ {
+ title: '行业新闻 - 协会动态',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen',
+ source: ['/news'],
+ target: '/cnljxh/news/8',
+ },
+ {
+ title: '行业新闻 - 企业动态',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen',
+ source: ['/news'],
+ target: '/cnljxh/news/9',
+ },
+ {
+ title: '行业新闻 - 行业动态',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen',
+ source: ['/news'],
+ target: '/cnljxh/news/11',
+ },
+ {
+ title: '政策法规',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen',
+ source: ['/news'],
+ target: '/cnljxh/news/12',
+ },
+ {
+ title: '行业标准 - 国家标准',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen',
+ source: ['/news'],
+ target: '/cnljxh/news/13',
+ },
+ {
+ title: '行业标准 - 行业标准',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen',
+ source: ['/news'],
+ target: '/cnljxh/news/14',
+ },
+ {
+ title: '行业标准 - 团体标准',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen',
+ source: ['/news'],
+ target: '/cnljxh/news/15',
+ },
+ {
+ title: '技术广角',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen',
+ source: ['/news'],
+ target: '/cnljxh/news/16',
+ },
+ {
+ title: '价格行情',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-jia-ge',
+ source: ['/price'],
+ target: '/cnljxh/price/299',
+ },
+ {
+ title: '双焦运费',
+ docs: 'https://docs.rsshub.app/routes/other#zhong-guo-lian-jiao-hang-ye-xie-hui-jia-ge',
+ source: ['/price'],
+ target: '/cnljxh/price/2143',
+ },
+ ],
+ },
+};
diff --git a/lib/v2/cnljxh/router.js b/lib/v2/cnljxh/router.js
new file mode 100644
index 000000000..c31dedddc
--- /dev/null
+++ b/lib/v2/cnljxh/router.js
@@ -0,0 +1,3 @@
+module.exports = (router) => {
+ router.get('/:category?/:id?', require('./'));
+};
diff --git a/website/docs/routes/other.mdx b/website/docs/routes/other.mdx
index ad0f3d8f2..25b588764 100644
--- a/website/docs/routes/other.mdx
+++ b/website/docs/routes/other.mdx
@@ -1212,6 +1212,84 @@ Specify options (in the format of query string) in parameter `routeParams` param
+## 中国炼焦行业协会 {#zhong-guo-lian-jiao-hang-ye-xie-hui}
+
+### 汇总 {#zhong-guo-lian-jiao-hang-ye-xie-hui-hui-zong}
+
+ 价格汇总']} radar="1" supportBT="1">
+ | 价格汇总 |
+ | -------- |
+ | 10039 |
+
+
+### 价格指数 {#zhong-guo-lian-jiao-hang-ye-xie-hui-jia-ge-zhi-shu}
+
+ 焦炭指数']} radar="1" supportBT="1">
+ | 焦炭指数 | 炼焦煤指数 |
+ | -------- | ---------- |
+ | 5575 | 5907 |
+
+
+### 分析数据 {#zhong-guo-lian-jiao-hang-ye-xie-hui-fen-xi-shu-ju}
+
+ 市场分析']} radar="1" supportBT="1">
+ | 市场分析 | 一周评述 | 核心数据 |
+ | -------- | -------- | -------- |
+ | 575 | 5573 | 5417 |
+
+
+### 新闻 {#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen}
+
+
+
+ 更多分类
+
+ #### 协会专区
+
+ | 协会简介 | 协会章程 | 协会领导 | 入会程序 | 组织机构 |
+ | -------- | -------- | -------- | -------- | -------- |
+ | 24 | 25 | 26 | 27 | 28 |
+
+ #### 协会公告
+
+ | 协会公告 |
+ | -------- |
+ | 10 |
+
+ #### 行业新闻
+
+ | 协会动态 | 企业动态 | 行业动态 |
+ | -------- | -------- | -------- |
+ | 8 | 9 | 11 |
+
+ #### 政策法规
+
+ | 政策法规 |
+ | -------- |
+ | 12 |
+
+ #### 行业标准
+
+ | 国家标准 | 行业标准 | 团体标准 |
+ | -------- | -------- | -------- |
+ | 13 | 14 | 15 |
+
+ #### 技术广角
+
+ | 技术广角 |
+ | -------- |
+ | 16 |
+
+
+
+### 价格 {#zhong-guo-lian-jiao-hang-ye-xie-hui-jia-ge}
+
+ 价格行情']} radar="1" supportBT="1">
+ | 价格行情 | 双焦运费 |
+ | -------- | -------- |
+ | 299 | 2143 |
+
+
## 中国期货业协会 {#zhong-guo-qi-huo-ye-xie-hui}
### 分析师园地 {#zhong-guo-qi-huo-ye-xie-hui-fen-xi-shi-yuan-di}