From 2fae18cb03d653e3523891426fd71667c5bf6ae4 Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Fri, 4 Dec 2020 23:46:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20=E4=B8=9C=E8=A5=BF=E6=99=BA?= =?UTF-8?q?=E5=BA=93=20(#6289)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/new-media.md | 63 ++++++++++++++++++++++++++++++++++++++ lib/router.js | 3 ++ lib/routes/dx2025/index.js | 52 +++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 lib/routes/dx2025/index.js diff --git a/docs/new-media.md b/docs/new-media.md index 5b78f63e1..a8b4b0cd0 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -792,6 +792,69 @@ area 分区选项 +## 东西智库 + +### 分类 + + + +内容类别 + +| 产业观察 | 行业报告 | 政策 & 成效 | +| -------------------- | ---------------- | ------------------ | +| industry-observation | industry-reports | policy-achievement | + +行业分类 + +| 行业 | 行业名称 | +| -------------------- | ----------------------------------------------------------------- | +| 新一代信息技术 | next-generation-information-technology-industry-reports | +| 高档数控机床和机器人 | high-grade-cnc-machine-tools-and-robots-industry-reports | +| 航空航天装备 | aerospace-equipment-industry-reports | +| 海工装备及高技术船舶 | marine-engineering-equipment-and-high-tech-ships-industry-reports | +| 先进轨道交通装备 | advanced-rail-transportation-equipment-industry-reports | +| 节能与新能源汽车 | energy-saving-and-new-energy-vehicles-industry-reports | +| 电力装备 | electric-equipment-industry-reports | +| 农机装备 | agricultural-machinery-equipment-industry-reports | +| 新材料 | new-material-industry-reports | +| 生物医药及医疗器械 | biomedicine-and-medical-devices-industry-reports | +| 现代服务业 | modern-service-industry-industry-reports | +| 制造业人才 | manufacturing-talent-industry-reports | + + + +### 标签 + + + +| 分类 | 分类名 | 分类 | 分类名 | +| ---------- | --------------------------------- | -------------- | ------------------------- | +| 3D 打印 | 3d_printing | 大数据 | dashuju | +| 5G | 5g | 大湾区 | d_w_q | +| AI | AI | 宏观经济 | macro_economy | +| 世界经济 | world_economy | 工业互联网 | industrial_internet | +| 云计算 | cloud_computing | 工业软件 | g_y_r_j | +| 人工智能 | rengongzhineng | 数字化转型 | digital_transformation | +| 人才 | personnel | 数字孪生 | digital_twin | +| 企业研究 | enterprise_research | 数字经济 | digital_economy | +| 信息安全 | information_safety | 数字货币 | digital-currency | +| 创新 | innovate | 数据中心 | data_center | +| 制造业 | manufacturing | 数据安全 | data_security | +| 动力电池 | power_battery | 新一代信息技术 | x_y_d_x_x_j_s | +| 区块链 | qukuailian | 新基建 | new_infrastructure | +| 医疗器械 | medical_apparatus_and_instruments | 新材料 | x_c_l | +| 半导体芯片 | semiconductor_chip | 新能源 | x_n_y | +| 新能源汽车 | new_energy_vehicles | 智能制造 | intelligent_manufacturing | +| 机器人 | robot | 机床 | machine_tool | +| 海工装备 | marine_engineering_equipment | 物联网 | wulianwang | +| 现代服务 | x_d_f_w | 生物医药 | biomedicine | +| 电力装备 | electric_equipment | 网络安全 | wangluoanquan | +| 航空航天 | aerospace | 虚拟现实 | virtual_reality | +| 装备制造业 | equipment_manufacturing_industry | 赋能 | empowerment | +| 轨道交通 | rail_transit | | | + + + ## 多知网 ### 首页 diff --git a/lib/router.js b/lib/router.js index d8318634f..8827ce34f 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3517,6 +3517,9 @@ router.get('/uisdc/news', require('./routes/uisdc/news')); router.get('/uisdc/zt/:title?', require('./routes/uisdc/zt')); router.get('/uisdc/topic/:title?/:sort?', require('./routes/uisdc/topic')); +// 东西智库 +router.get('/dx2025/:type?/:category?', require('./routes/dx2025/index')); + // DeepL router.get('/deepl/blog/:lang?', require('./routes/deepl/blog')); diff --git a/lib/routes/dx2025/index.js b/lib/routes/dx2025/index.js new file mode 100644 index 000000000..3f5494050 --- /dev/null +++ b/lib/routes/dx2025/index.js @@ -0,0 +1,52 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const type = ctx.params.type || ''; + const category = ctx.params.category || ''; + + const rootUrl = 'https://www.dx2025.com'; + const currentUrl = `${rootUrl}${type === '' ? '' : `/archives/${type === 'tag' ? `tag${category === '' ? '' : `/${category}`}` : `category/${type}${category === '' ? '' : `/${category}`}`}`}`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('.entry-title a') + .slice(0, 10) + .map((_, item) => { + item = $(item); + return { + title: item.text(), + link: item.attr('href'), + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + + item.author = content('.entry-author-name').text(); + item.description = content('.bpp-post-content, .entry-content').html(); + item.pubDate = new Date(content('.entry-date').attr('datetime')).toUTCString(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +};