feat(route): add leiphone (#8592)
This commit is contained in:
parent
ac596b8634
commit
ba9f343c79
|
|
@ -2018,6 +2018,78 @@ column 为 third 时可选的 category:
|
|||
|
||||
<Route author="xyqfer" example="/laosiji/hotshow/128" path="/laosiji/hotshow/:id" :paramsDesc="['节目 id']"/>
|
||||
|
||||
## 雷峰网
|
||||
|
||||
### 最新文章
|
||||
|
||||
<Route author="vlcheng" example="/leiphone" path="/leiphone"/>
|
||||
|
||||
### 业界资讯
|
||||
|
||||
<Route author="vlcheng" example="/leiphone/newsflash" path="/leiphone/newsflash"/>
|
||||
|
||||
### 栏目
|
||||
|
||||
<Route author="vlcheng" example="/leiphone/category/industrynews" path="/leiphone/category/industrynews/:catname" :paramsDesc="['网站顶部分类栏目']">
|
||||
|
||||
- 主栏目
|
||||
|
||||
| 业界 | 人工智能 | 智能驾驶 | 数智化 | 金融科技 | 医疗科技 | 芯片 | 政企安全 | 智慧城市 | 行业云 | 工业互联网 | 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 |
|
||||
|
||||
</Route>
|
||||
|
||||
## 留园网
|
||||
|
||||
### 分站
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
module.exports = {
|
||||
'/leiphone': ['vlcheng'],
|
||||
'/leiphone/category/:catname': ['vlcheng'],
|
||||
'/leiphone/newsflash': ['vlcheng'],
|
||||
};
|
||||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
@ -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'
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/:do?/:keyword?', require('./index'));
|
||||
router.get('/newsflash', require('./newsflash'));
|
||||
};
|
||||
|
|
@ -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,
|
||||
};
|
||||
Loading…
Reference in New Issue