diff --git a/docs/new-media.md b/docs/new-media.md index 75f4718e1..6ab726ef0 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -2018,6 +2018,78 @@ column 为 third 时可选的 category: +## 雷峰网 + +### 最新文章 + + + +### 业界资讯 + + + +### 栏目 + + + +- 主栏目 + +| 业界 | 人工智能 | 智能驾驶 | 数智化 | 金融科技 | 医疗科技 | 芯片 | 政企安全 | 智慧城市 | 行业云 | 工业互联网 | AIoT | +| ------------ | -------- | -------------- | --------------- | -------- | -------- | ----- | ---------- | --------- | ------------- | ------------------ | ---- | +| industrynews | ai | transportation | digitalindustry | fintech | aihealth | chips | gbsecurity | smartcity | industrycloud | IndustrialInternet | iot | + +- 子栏目 + + - 人工智能 + + | 学术 | 开发者 | + | -------- | -------- | + | academic | yanxishe | + + - 数智化 + + | 零售数智化 | 金融数智化 | 工业数智化 | 医疗数智化 | 城市数智化 | + | ---------- | ---------- | ---------- | ---------- | ----------- | + | redigital | findigital | mandigital | medigital | citydigital | + + - 金融科技 + + | 科技巨头 | 银行AI | 金融云 | 风控与安全 | + | -------- | ------ | ------------ | ------------ | + | BigTech | bank | FinanceCloud | DataSecurity | + + - 医疗科技 + + | 医疗AI | 投融资 | 医疗器械 | 互联网医疗 | 生物医药 | 健康险 | + | -------- | ------ | -------- | ---------------- | ------------ | ------------ | + | healthai | touzi | qixie | hulianwangyiliao | shengwuyiyao | jiankangxian | + + - 芯片 + + | 材料设备 | 芯片设计 | 晶圆代工 | 封装测试 | + | --------- | ---------- | ------------- | --------- | + | materials | chipdesign | manufacturing | packaging | + + - 智慧城市 + + | 智慧安防 | 智慧教育 | 智慧交通 | 智慧社区 | 智慧零售 | 智慧政务 | 智慧地产 | + | ------------- | -------------- | ------------------- | -------------- | -------------- | --------------- | -------- | + | smartsecurity | smarteducation | smarttransportation | smartcommunity | smartretailing | smartgovernment | proptech | + + - 工业互联网 + + | 工业软件 | 工业安全 | 5G工业互联网 | 工业转型实践 | + | ---------- | -------- | ------------ | ------------ | + | gysoftware | gysafety | 5ggy | gypratice | + + - AIoT + + | 物联网 | 智能硬件 | 机器人 | 智能家居 | + | ------ | -------- | ------ | --------- | + | 5G | arvr | robot | smarthome | + + + ## 留园网 ### 分站 diff --git a/lib/v2/leiphone/index.js b/lib/v2/leiphone/index.js new file mode 100644 index 000000000..881d4f928 --- /dev/null +++ b/lib/v2/leiphone/index.js @@ -0,0 +1,25 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const utils = require('./utils'); + +module.exports = async (ctx) => { + const todo = ctx.params.do ?? ''; + const keyword = ctx.params.keyword ?? ''; + const rootUrl = 'https://www.leiphone.com'; + const url = `${rootUrl}${todo}${keyword}`; + const res = await got.get(url); + const $ = cheerio.load(res.data); + + const list = $('.word > h3 > a') + .slice(0, 10) + .get() + .map((e) => $(e).attr('href')); + const items = await utils.ProcessFeed(list, ctx.cache); + + ctx.state.data = { + title: `雷峰网${todo === 'category' ? ` ${keyword}` : ''}`, + description: '雷峰网 - 读懂智能&未来', + link: url, + item: items, + }; +}; \ No newline at end of file diff --git a/lib/v2/leiphone/maintainer.js b/lib/v2/leiphone/maintainer.js new file mode 100644 index 000000000..e648d7240 --- /dev/null +++ b/lib/v2/leiphone/maintainer.js @@ -0,0 +1,5 @@ +module.exports = { + '/leiphone': ['vlcheng'], + '/leiphone/category/:catname': ['vlcheng'], + '/leiphone/newsflash': ['vlcheng'], +}; diff --git a/lib/v2/leiphone/newsflash.js b/lib/v2/leiphone/newsflash.js new file mode 100644 index 000000000..d455bb160 --- /dev/null +++ b/lib/v2/leiphone/newsflash.js @@ -0,0 +1,19 @@ +const got = require('@/utils/got'); +const utils = require('./utils'); +// const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'https://www.leiphone.com/site/YejieKuaixun'; + const res = await got.get(url); + const article = (res.data || {}).article || []; + + const list = article.map((item) => (item.url)); + const items = await utils.ProcessFeed(list, ctx.cache); + + ctx.state.data = { + title: '雷峰网 业界资讯', + description: '雷峰网 - 读懂智能&未来', + link: url, + item: items, + }; +}; \ No newline at end of file diff --git a/lib/v2/leiphone/radar.js b/lib/v2/leiphone/radar.js new file mode 100644 index 000000000..7b2d18030 --- /dev/null +++ b/lib/v2/leiphone/radar.js @@ -0,0 +1,25 @@ +module.exports = { + 'leiphone.com': { + _name: '雷峰网', + '.': [ + { + title: '最新文章', + docs: 'https://docs.rsshub.app/new-media.html#lei-feng-wang-zui-xin-wen-zhang', + source: ['/'], + target: '/leiphone' + }, + { + title: '栏目', + docs: 'https://docs.rsshub.app/new-media.html#lei-feng-wang-lan-mu', + source: ['/:catename'], + target: '/leiphone/category/:catname' + }, + { + title: '业界资讯', + docs: 'https://docs.rsshub.app/new-media.html#lei-feng-wang-ye-jie-zi-xun', + source: ['/'], + target: '/leiphone/newsflash' + }, + ], + }, +}; diff --git a/lib/v2/leiphone/router.js b/lib/v2/leiphone/router.js new file mode 100644 index 000000000..e28c14fcf --- /dev/null +++ b/lib/v2/leiphone/router.js @@ -0,0 +1,4 @@ +module.exports = function (router) { + router.get('/:do?/:keyword?', require('./index')); + router.get('/newsflash', require('./newsflash')); +}; diff --git a/lib/v2/leiphone/utils.js b/lib/v2/leiphone/utils.js new file mode 100644 index 000000000..7f7ad7ebe --- /dev/null +++ b/lib/v2/leiphone/utils.js @@ -0,0 +1,41 @@ +const cheerio = require('cheerio'); +const got = require('@/utils/got'); +const dateParser = require('@/utils/dateParser'); +const url = require('url'); + +const ProcessFeed = async (list, cache) => { + const host = 'https://www.leiphone.com'; + + const items = await Promise.all( + list.map(async (e) => { + const link = url.resolve(host, e); + + const single = await cache.tryGet(link, async () => { + const response = await got.get(link); + + const $ = cheerio.load(response.data); + + let description = ''; + if ($('.top-img').html() !== null) { + description += $('.top-img').html(); + } + + return { + title: $('.headTit').text(), + description: description + $('.article-lead').text() + $('.lph-article-comView').html(), + pubDate: dateParser($('.time').text(), 8), + author: $('.aut > a').text(), + link, + }; + }); + + return Promise.resolve(single); + }) + ); + + return items; +}; + +module.exports = { + ProcessFeed, +};