feat(route): add 中国炼焦行业协会 (#14074)
* feat(route): add 中国炼焦行业协会 * fix: remove subheadings for radar links * fix typo
This commit is contained in:
parent
47068bfae5
commit
e6a54c2921
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
module.exports = {
|
||||
'/collect/:id?': ['nczitzk'],
|
||||
'/date/:id?': ['nczitzk'],
|
||||
'/info/:id?': ['nczitzk'],
|
||||
'/news/:id?': ['nczitzk'],
|
||||
'/price/:id?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -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',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/:category?/:id?', require('./'));
|
||||
};
|
||||
|
|
@ -1212,6 +1212,84 @@ Specify options (in the format of query string) in parameter `routeParams` param
|
|||
|
||||
<Route author="Fatpandac" example="/piyao/jrpy" path="/piyao/jrpy" />
|
||||
|
||||
## 中国炼焦行业协会 {#zhong-guo-lian-jiao-hang-ye-xie-hui}
|
||||
|
||||
### 汇总 {#zhong-guo-lian-jiao-hang-ye-xie-hui-hui-zong}
|
||||
|
||||
<Route author="nczitzk" example="/cnljxh/collect" path="/cnljxh/collect/:id?" paramsDesc={['栏目 id,见下表,可在对应栏目页 URL 中找到,默认为 10039,即市场价格 > 价格汇总']} radar="1" supportBT="1">
|
||||
| 价格汇总 |
|
||||
| -------- |
|
||||
| 10039 |
|
||||
</Route>
|
||||
|
||||
### 价格指数 {#zhong-guo-lian-jiao-hang-ye-xie-hui-jia-ge-zhi-shu}
|
||||
|
||||
<Route author="nczitzk" example="/cnljxh/date" path="/cnljxh/date/:id?" paramsDesc={['栏目 id,见下表,可在对应栏目页 URL 中找到,默认为 5575,即价格指数 > 焦炭指数']} radar="1" supportBT="1">
|
||||
| 焦炭指数 | 炼焦煤指数 |
|
||||
| -------- | ---------- |
|
||||
| 5575 | 5907 |
|
||||
</Route>
|
||||
|
||||
### 分析数据 {#zhong-guo-lian-jiao-hang-ye-xie-hui-fen-xi-shu-ju}
|
||||
|
||||
<Route author="nczitzk" example="/cnljxh/info" path="/cnljxh/info/:id?" paramsDesc={['栏目 id,见下表,可在对应栏目页 URL 中找到,默认为 575,即分析数据 > 市场分析']} radar="1" supportBT="1">
|
||||
| 市场分析 | 一周评述 | 核心数据 |
|
||||
| -------- | -------- | -------- |
|
||||
| 575 | 5573 | 5417 |
|
||||
</Route>
|
||||
|
||||
### 新闻 {#zhong-guo-lian-jiao-hang-ye-xie-hui-xin-wen}
|
||||
|
||||
<Route author="nczitzk" example="/cnljxh/news" path="/cnljxh/news/:id?" paramsDesc={['栏目 id,见下表,可在对应栏目页 URL 中找到,默认为 10,即协会公告']} radar="1" supportBT="1">
|
||||
<details>
|
||||
<summary>更多分类</summary>
|
||||
|
||||
#### 协会专区
|
||||
|
||||
| 协会简介 | 协会章程 | 协会领导 | 入会程序 | 组织机构 |
|
||||
| -------- | -------- | -------- | -------- | -------- |
|
||||
| 24 | 25 | 26 | 27 | 28 |
|
||||
|
||||
#### 协会公告
|
||||
|
||||
| 协会公告 |
|
||||
| -------- |
|
||||
| 10 |
|
||||
|
||||
#### 行业新闻
|
||||
|
||||
| 协会动态 | 企业动态 | 行业动态 |
|
||||
| -------- | -------- | -------- |
|
||||
| 8 | 9 | 11 |
|
||||
|
||||
#### 政策法规
|
||||
|
||||
| 政策法规 |
|
||||
| -------- |
|
||||
| 12 |
|
||||
|
||||
#### 行业标准
|
||||
|
||||
| 国家标准 | 行业标准 | 团体标准 |
|
||||
| -------- | -------- | -------- |
|
||||
| 13 | 14 | 15 |
|
||||
|
||||
#### 技术广角
|
||||
|
||||
| 技术广角 |
|
||||
| -------- |
|
||||
| 16 |
|
||||
</details>
|
||||
</Route>
|
||||
|
||||
### 价格 {#zhong-guo-lian-jiao-hang-ye-xie-hui-jia-ge}
|
||||
|
||||
<Route author="nczitzk" example="/cnljxh/price" path="/cnljxh/price/:id?" paramsDesc={['栏目 id,见下表,可在对应栏目页 URL 中找到,默认为 299,即市场价格 > 价格行情']} radar="1" supportBT="1">
|
||||
| 价格行情 | 双焦运费 |
|
||||
| -------- | -------- |
|
||||
| 299 | 2143 |
|
||||
</Route>
|
||||
|
||||
## 中国期货业协会 {#zhong-guo-qi-huo-ye-xie-hui}
|
||||
|
||||
### 分析师园地 {#zhong-guo-qi-huo-ye-xie-hui-fen-xi-shi-yuan-di}
|
||||
|
|
|
|||
Loading…
Reference in New Issue