feat(route): add 快科技 (#8440)
This commit is contained in:
parent
c626a9cc7c
commit
a9f4ab44d3
|
|
@ -1833,7 +1833,53 @@ column 为 third 时可选的 category:
|
|||
|
||||
</Route>
|
||||
|
||||
## 快科技(原驱动之家)
|
||||
## 快科技
|
||||
|
||||
### 新闻
|
||||
|
||||
<Route author="nczitzk" example="/mydrivers" path="/mydrivers/:type?/:id?" :paramsDesc="['类型,见下表,默认为最新', '编号,可在对应页面地址栏中找到']">
|
||||
|
||||
::: tip 提示
|
||||
|
||||
使用 **类型** 表中的两个参数时,编号应留空,如:**最新** 为 [`/mydrivers/new`](https://rsshub.app/mydrivers/new)
|
||||
|
||||
使用 **编号** 表中的参数不应遗漏对应类型参数,如 **电脑** 为 [`/mydrivers/bcid/801`](https://rsshub.app/mydrivers/bcid/801)
|
||||
|
||||
:::
|
||||
|
||||
类型
|
||||
|
||||
| 最新 | 热门 |
|
||||
| ---- | ---- |
|
||||
| new | hot |
|
||||
|
||||
编号
|
||||
|
||||
| 最新 | 最热 | 电脑 | 手机 | 汽车 | 业界 |
|
||||
| ------ | ------ | -------- | -------- | -------- | -------- |
|
||||
| ac/new | ac/hot | bcid/801 | bcid/802 | bcid/807 | bcid/803 |
|
||||
|
||||
| 科学 | 排行 | 评测 | 安卓 | 苹果 | CPU |
|
||||
| -------- | -------- | -------- | -------- | ------- | ------ |
|
||||
| tid/1000 | tid/1001 | tid/1002 | icid/121 | cid/201 | cid/13 |
|
||||
|
||||
| 显卡 | 一图 | 阿里 | 微软 | 百度 | 影视 |
|
||||
| ------ | -------- | -------- | ------- | ------- | -------- |
|
||||
| cid/12 | tid/1003 | icid/270 | icid/90 | icid/67 | bcid/809 |
|
||||
|
||||
| 游戏 | 路由器 | PS5 | Xbox | 华为 | OPPO |
|
||||
| -------- | ------ | --------- | -------- | -------- | -------- |
|
||||
| bcid/806 | cid/38 | icid/6950 | icid/194 | icid/136 | icid/148 |
|
||||
|
||||
| 小米 | VIVO | 三星 | 魅族 | 一加 | 特斯拉 |
|
||||
| --------- | -------- | -------- | -------- | -------- | --------- |
|
||||
| icid/9355 | icid/288 | icid/154 | icid/140 | icid/385 | icid/1193 |
|
||||
|
||||
| 比亚迪 | 小鹏 | 蔚来 | 理想 | 奔驰 | 宝马 | 大众 |
|
||||
| -------- | --------- | --------- | ---------- | -------- | -------- | -------- |
|
||||
| icid/770 | icid/7259 | icid/7318 | icid/12947 | icid/429 | icid/461 | icid/481 |
|
||||
|
||||
</Route>
|
||||
|
||||
### 最新新闻
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,110 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const titles = {
|
||||
'': { '': '最新' },
|
||||
new: { '': '最新' },
|
||||
hot: { '': '最热' },
|
||||
ac: {
|
||||
new: '最新',
|
||||
hot: '最热',
|
||||
},
|
||||
bcid: {
|
||||
801: '电脑',
|
||||
802: '手机',
|
||||
803: '业界',
|
||||
806: '游戏',
|
||||
807: '汽车',
|
||||
809: '影视',
|
||||
},
|
||||
tid: {
|
||||
1000: '科学',
|
||||
1001: '排行',
|
||||
1002: '评测',
|
||||
1003: '一图',
|
||||
},
|
||||
icid: {
|
||||
67: '百度',
|
||||
90: '微软',
|
||||
121: '安卓',
|
||||
136: '华为',
|
||||
140: '魅族',
|
||||
148: 'OPPO',
|
||||
154: '三星',
|
||||
194: 'Xbox',
|
||||
270: '阿里',
|
||||
288: 'VIVO',
|
||||
385: '一加',
|
||||
429: '奔驰',
|
||||
461: '宝马',
|
||||
481: '大众',
|
||||
770: '比亚迪',
|
||||
1193: '特斯拉',
|
||||
6950: 'PS5',
|
||||
7259: '小鹏',
|
||||
7318: '蔚来',
|
||||
9355: '小米',
|
||||
12947: '理想',
|
||||
},
|
||||
cid: {
|
||||
12: '显卡',
|
||||
13: 'CPU',
|
||||
38: '路由器',
|
||||
201: '苹果',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type ?? '';
|
||||
const id = ctx.params.id ?? '';
|
||||
|
||||
const rootUrl = 'https://m.mydrivers.com';
|
||||
const currentUrl = `${rootUrl}/${type === '' || type === 'ac' ? 'm/newslist.ashx' : 'newsclass.aspx'}${type ? (id ? `?${type}=${id}` : `?ac=${type}`) : ''}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.newst a')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${rootUrl}${item.attr('href')}`,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
content('.ab, .bb').remove();
|
||||
|
||||
item.author = content('.writer').text();
|
||||
item.description = content('#content').html();
|
||||
item.pubDate = timezone(parseDate(content('.news_t1 ul li').eq(1).text().trim(), 'YYYY年MM月DD日 mm:ss'), +8);
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${titles[type][id]} - 快科技`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/:type?/:id?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'mydrivers.com': {
|
||||
_name: '快科技',
|
||||
'.': [
|
||||
{
|
||||
title: '新闻',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#kuai-ke-ji-xin-wen',
|
||||
source: ['/'],
|
||||
target: '/mydrivers/:type?/:id?',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/:type?/:id?', require('./index'));
|
||||
};
|
||||
Loading…
Reference in New Issue