feat(route): add 电动邦 (#9897)
* feat(route): add 电动邦 * docs: fix h2 heading
This commit is contained in:
@@ -1616,6 +1616,32 @@ Supported sub-sites:
|
||||
|
||||
<Route author="nczitzk" example="/dedao/knowledge" path="/dedao/knowledge/:topic?/:type?" :paramsDesc="['话题 id,可在话题页 URL 中找到', '分享类型,`true` 指精选,`false` 指最新,默认为精选']"/>
|
||||
|
||||
## 电动邦
|
||||
|
||||
### 资讯
|
||||
|
||||
<Route author="Fatpandac" example="/diandong/news" path="/diandong/news/:cate?" :paramsDesc="['分类,见下表,默认为推荐']">
|
||||
|
||||
分类
|
||||
|
||||
| 推荐 | 新车 | 导购 | 试驾 | 用车 | 技术 | 政策 | 行业 |
|
||||
| -- | -- | -- | -- | -- | -- | -- | -- |
|
||||
| 0 | 29 | 61 | 30 | 75 | 22 | 24 | 23 |
|
||||
|
||||
</Route>
|
||||
|
||||
### 电动号
|
||||
|
||||
<Route author="Fatpandac" example="/diandong/ddh" path="/diandong/ddh/:cate?" :paramsDesc="['分类,见下表,默认为全部']">
|
||||
|
||||
分类
|
||||
|
||||
| 全部 | 新车 | 导购 | 评测 | 新闻 | 技术 | 政策 | 用车 | 二手车 |
|
||||
| -- | -- | -- | -- | -- | -- | -- | -- | --- |
|
||||
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|
||||
|
||||
</Route>
|
||||
|
||||
## 电商报
|
||||
|
||||
### 分区
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const rootUrl = 'https://webapi.diandong.com';
|
||||
|
||||
const titleMap = {
|
||||
0: '全部',
|
||||
1: '新车',
|
||||
2: '导购',
|
||||
3: '评测',
|
||||
4: '新闻',
|
||||
5: '技术',
|
||||
6: '政策',
|
||||
7: '用车',
|
||||
8: '二手车',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const cate = ctx.params.cate ?? 0;
|
||||
const limit = ctx.query.limit ? Number(ctx.query.limit) : 25;
|
||||
const url = `${rootUrl}/content/ddhList?category_id=${cate}&page=1&size=${limit}&content_ids=`;
|
||||
|
||||
const response = await got(url);
|
||||
const data = response.data.data.list;
|
||||
const list = data.map((item) => ({
|
||||
title: item.title,
|
||||
pubDate: parseDate(item.published),
|
||||
author: item.author,
|
||||
link: `https://www.diandong.com/news/${item.contentid}.html`,
|
||||
}));
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const $ = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = $('#gallery-selector').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `电动邦 - 电动号 - ${titleMap[cate]}`,
|
||||
link: 'https://www.diandong.com/news/ddh',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
'/news/:cate?': ['Fatpandac'],
|
||||
'/ddh/:cate?': ['Fatpandac'],
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const rootUrl = 'https://webapi.diandong.com';
|
||||
|
||||
const titleMap = {
|
||||
0: '推荐',
|
||||
29: '新车',
|
||||
61: '导购',
|
||||
30: '试驾',
|
||||
75: '用车',
|
||||
22: '技术',
|
||||
24: '政策',
|
||||
23: '行业',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const cate = ctx.params.cate ?? 0;
|
||||
const limit = ctx.query.limit ? Number(ctx.query.limit) : 25;
|
||||
const url = `${rootUrl}/content/list?page=1&size=${limit}&source_id=12&content_type=news&content_ids=&category_id=${cate}`;
|
||||
|
||||
const response = await got(url);
|
||||
const data = response.data.data.list;
|
||||
const list = data.map((item) => ({
|
||||
title: item.title,
|
||||
pubDate: parseDate(item.published),
|
||||
author: item.author,
|
||||
link: `https://www.diandong.com/news/${item.contentid}.html`,
|
||||
}));
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const $ = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = $('#gallery-selector').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `电动邦 - ${titleMap[cate]}`,
|
||||
link: 'https://www.diandong.com/news',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'diandong.com': {
|
||||
_name: '电动邦',
|
||||
'.': [
|
||||
{
|
||||
title: '资讯',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#dong-qiu-di',
|
||||
source: ['/news'],
|
||||
target: '/diandong/news/:cate',
|
||||
},
|
||||
{
|
||||
title: '电动号',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#dong-qiu-di',
|
||||
source: ['/news/ddh'],
|
||||
target: '/diandong/ddh/:cate',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/news/:cate?', require('./news'));
|
||||
router.get('/ddh/:cate?', require('./ddh'));
|
||||
};
|
||||
Reference in New Issue
Block a user