mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-19 09:52:21 +08:00
feat(route): add 快科技 (#13312)
* feat(route): add 快科技 * fix typo * update lib/v2/mydrivers/rank.js ---------
This commit is contained in:
+1
-1
@@ -995,7 +995,7 @@ router.get('/dekudeals/:type', lazyloadRouteHandler('./routes/dekudeals'));
|
||||
router.get('/metacritic/release/:platform/:type/:sort?', lazyloadRouteHandler('./routes/metacritic/release'));
|
||||
|
||||
// 快科技(原驱动之家)
|
||||
router.get('/kkj/news', lazyloadRouteHandler('./routes/kkj/news'));
|
||||
// router.get('/kkj/news', lazyloadRouteHandler('./routes/kkj/news'));
|
||||
|
||||
// sixthtone
|
||||
router.get('/sixthtone/news', lazyloadRouteHandler('./routes/sixthtone/news'));
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const parser = require('@/utils/rss-parser');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const feed = await parser.parseURL('http://rss.mydrivers.com/rss.aspx?Tid=1');
|
||||
|
||||
const ProcessFeed = (data) => {
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
// 移除广告等内容
|
||||
$('.news_info .weixin ~ div').remove();
|
||||
$('.news_info .weixin').remove();
|
||||
$('.news_info script').remove();
|
||||
|
||||
// 提取内容
|
||||
return $('.news_info').html();
|
||||
};
|
||||
|
||||
const items = await Promise.all(
|
||||
feed.items.map(async (item) => {
|
||||
const cache = await ctx.cache.get(item.link);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const description = ProcessFeed(response.data);
|
||||
|
||||
const single = {
|
||||
title: item.title,
|
||||
description,
|
||||
pubDate: item.pubDate,
|
||||
link: item.link,
|
||||
author: item.author,
|
||||
};
|
||||
ctx.cache.set(item.link, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: feed.title,
|
||||
link: feed.link,
|
||||
description: feed.description,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const parser = require('@/utils/rss-parser');
|
||||
|
||||
const { rootUrl, rootRSSUrl, title, categories, getInfo, processItems } = require('./util');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 100;
|
||||
|
||||
const queryString = id ? `?cid=${id}` : '';
|
||||
const currentUrl = new URL(id ? `newsclass.aspx${queryString}` : '', rootUrl).href;
|
||||
|
||||
const rssUrl = new URL(`rss.aspx${queryString}`, rootRSSUrl).href;
|
||||
|
||||
const feed = await parser.parseURL(rssUrl);
|
||||
|
||||
let items = feed.items.slice(0, limit).map((item) => ({
|
||||
title: item.title,
|
||||
link: item.link,
|
||||
description: item.content,
|
||||
author: item.creator,
|
||||
category: item.categories,
|
||||
guid: item.guid.match(/\/(\d+)\.htm/)[1],
|
||||
pubDate: parseDate(item.isoDate),
|
||||
}));
|
||||
|
||||
if (id) {
|
||||
items = await processItems(items, ctx.cache.tryGet);
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
...(await getInfo(currentUrl, ctx.cache.tryGet)),
|
||||
...{
|
||||
item: items,
|
||||
title: `${title} - ${feed.title.split(/_/).pop() || categories.zhibo}`,
|
||||
},
|
||||
};
|
||||
};
|
||||
+41
-90
@@ -2,109 +2,60 @@ const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
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: '苹果',
|
||||
},
|
||||
};
|
||||
const { rootUrl, title, categories, convertToQueryString, getInfo, processItems } = require('./util');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type ?? '';
|
||||
const id = ctx.params.id ?? '';
|
||||
let { category = 'new' } = ctx.params;
|
||||
|
||||
const rootUrl = 'https://m.mydrivers.com';
|
||||
const currentUrl = `${rootUrl}/${type === '' || type === 'ac' ? 'm/newslist.ashx' : 'newsclass.aspx'}${type ? (id ? `?${type}=${id}` : `?ac=${type}`) : ''}`;
|
||||
let newTitle = '';
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
if (!/^(\w+\/\w+)$/.test(category)) {
|
||||
newTitle = `${title} - ${categories.hasOwnProperty(category) ? categories[category] : categories[Object.keys(categories)[0]]}`;
|
||||
category = `ac/${category}`;
|
||||
}
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 20;
|
||||
|
||||
const list = $('.newst a')
|
||||
.map((_, item) => {
|
||||
const queryString = convertToQueryString(category);
|
||||
const currentUrl = new URL(`newsclass.aspx${queryString}`, rootUrl).href;
|
||||
|
||||
const apiUrl = new URL(`m/newslist.ashx${queryString}`, rootUrl).href;
|
||||
|
||||
const { data: response } = await got(apiUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
let items = $('li[data-id]')
|
||||
.slice(0, limit)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${rootUrl}${item.attr('href')}`,
|
||||
title: item.find('div.news_title').text(),
|
||||
link: new URL(item.find('div.news_title span.newst a').prop('href'), rootUrl).href,
|
||||
description: art(path.join(__dirname, 'templates/description.art'), {
|
||||
image: item.find('a.newsimg img').prop('src'),
|
||||
}),
|
||||
author: item.find('p.tname').text(),
|
||||
guid: item.prop('data-id'),
|
||||
pubDate: timezone(parseDate(item.find('p.ttime').text()), +8),
|
||||
comments: item.find('a.tpinglun').text() ? parseInt(item.find('a.tpinglun').text(), 10) : 0,
|
||||
};
|
||||
})
|
||||
.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;
|
||||
})
|
||||
)
|
||||
);
|
||||
items = await processItems(items, ctx.cache.tryGet);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${titles[type][id]} - 快科技`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
...(await getInfo(currentUrl, ctx.cache.tryGet)),
|
||||
...Object.fromEntries(
|
||||
Object.entries({
|
||||
item: items,
|
||||
title: newTitle,
|
||||
}).filter(([value]) => value)
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
module.exports = {
|
||||
'/:type?/:id?': ['nczitzk'],
|
||||
'/hot': ['nczitzk'],
|
||||
'/new': ['kt286', 'nczitzk'],
|
||||
'/rank/:range?': ['nczitzk'],
|
||||
'/zhibo': ['nczitzk'],
|
||||
'/:category?': ['nczitzk'],
|
||||
};
|
||||
|
||||
+205
-4
@@ -1,12 +1,213 @@
|
||||
module.exports = {
|
||||
'mydrivers.com': {
|
||||
_name: '快科技',
|
||||
'.': [
|
||||
m: [
|
||||
{
|
||||
title: '新闻',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-xin-wen',
|
||||
title: '最新',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-zui-xin',
|
||||
source: ['/'],
|
||||
target: '/mydrivers/:type?/:id?',
|
||||
target: '/mydrivers/new',
|
||||
},
|
||||
{
|
||||
title: '热门',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-re-men',
|
||||
source: ['/'],
|
||||
target: '/mydrivers/hot',
|
||||
},
|
||||
{
|
||||
title: '发布会',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fa-bu-hui',
|
||||
source: ['/'],
|
||||
target: '/mydrivers/zhibo',
|
||||
},
|
||||
{
|
||||
title: '排行',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-pai-hang',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/rank',
|
||||
},
|
||||
{
|
||||
title: '分类',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: (params, url) => {
|
||||
url = new URL(url);
|
||||
|
||||
const theParam = [...url.searchParams.entries()]
|
||||
.filter(([key, value]) => key && value !== '')
|
||||
.map(([key, value]) => `${key}/${value}`)
|
||||
.pop();
|
||||
|
||||
return `/mydrivers/${theParam}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '板块 - 电脑',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/bcid/801',
|
||||
},
|
||||
{
|
||||
title: '板块 - 手机',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/bcid/802',
|
||||
},
|
||||
{
|
||||
title: '板块 - 汽车',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/bcid/807',
|
||||
},
|
||||
{
|
||||
title: '板块 - 业界',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/bcid/803',
|
||||
},
|
||||
{
|
||||
title: '板块 - 游戏',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/bcid/806',
|
||||
},
|
||||
{
|
||||
title: '话题 - 科学',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/tid/1000',
|
||||
},
|
||||
{
|
||||
title: '话题 - 排行',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/tid/1001',
|
||||
},
|
||||
{
|
||||
title: '话题 - 评测',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/tid/1002',
|
||||
},
|
||||
{
|
||||
title: '话题 - 一图',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/tid/1003',
|
||||
},
|
||||
{
|
||||
title: '品牌 - 安卓',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/121',
|
||||
},
|
||||
{
|
||||
title: '品牌 - 阿里',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/270',
|
||||
},
|
||||
{
|
||||
title: '品牌 - 微软',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/90',
|
||||
},
|
||||
{
|
||||
title: '品牌 - 百度',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/67',
|
||||
},
|
||||
{
|
||||
title: '品牌 - PS5',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/6950',
|
||||
},
|
||||
{
|
||||
title: '品牌 - Xbox',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/194',
|
||||
},
|
||||
{
|
||||
title: '品牌 - 华为',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/136',
|
||||
},
|
||||
{
|
||||
title: '品牌 - 小米',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/9355',
|
||||
},
|
||||
{
|
||||
title: '品牌 - VIVO',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/288',
|
||||
},
|
||||
{
|
||||
title: '品牌 - 三星',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/154',
|
||||
},
|
||||
{
|
||||
title: '品牌 - 魅族',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/140',
|
||||
},
|
||||
{
|
||||
title: '品牌 - 一加',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/385',
|
||||
},
|
||||
{
|
||||
title: '品牌 - 比亚迪',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/770',
|
||||
},
|
||||
{
|
||||
title: '品牌 - 小鹏',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/7259',
|
||||
},
|
||||
{
|
||||
title: '品牌 - 蔚来',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/7318',
|
||||
},
|
||||
{
|
||||
title: '品牌 - 理想',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/12947',
|
||||
},
|
||||
{
|
||||
title: '品牌 - 奔驰',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/429',
|
||||
},
|
||||
{
|
||||
title: '品牌 - 宝马',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/461',
|
||||
},
|
||||
{
|
||||
title: '品牌 - 大众',
|
||||
docs: 'https://docs.rsshub.app/routes/new-media#kuai-ke-ji-fen-lei',
|
||||
source: ['/newsclass.aspx'],
|
||||
target: '/mydrivers/icid/481',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const { rootUrl, getInfo, processItems } = require('./util');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { range = '0' } = ctx.params;
|
||||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 10;
|
||||
|
||||
const currentUrl = new URL('newsclass.aspx?tid=1001', rootUrl).href;
|
||||
|
||||
const apiUrl = new URL(`m/newslist.ashx?ac=rank&tid=${range}`, rootUrl).href;
|
||||
|
||||
const { data: response } = await got(apiUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
let items = $('a')
|
||||
.toArray()
|
||||
.filter((item) => /\/(\d+)\.html?/.test($(item).prop('href')))
|
||||
.slice(0, limit)
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
const link = item.prop('href');
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: new URL(link, rootUrl).href,
|
||||
guid: link.match(/\/(\d+)\.html?/)[1],
|
||||
};
|
||||
});
|
||||
|
||||
items = await processItems(items, ctx.cache.tryGet);
|
||||
|
||||
ctx.state.data = {
|
||||
item: items,
|
||||
...(await getInfo(currentUrl, ctx.cache.tryGet, parseInt(range, 10))),
|
||||
};
|
||||
};
|
||||
@@ -1,3 +1,6 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/:type?/:id?', require('./index'));
|
||||
router.get('/cid/:id?', require('./cid'));
|
||||
router.get('/rank/:range?', require('./rank'));
|
||||
router.get('/zhibo', require('./cid'));
|
||||
router.get('/:category*', require('./'));
|
||||
};
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{{ if image }}
|
||||
<figure>
|
||||
<img src="{{ image }}">
|
||||
</figure>
|
||||
{{ /if }}
|
||||
@@ -0,0 +1,125 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const domain = 'mydrivers.com';
|
||||
const rootUrl = `https://m.${domain}`;
|
||||
const rootRSSUrl = `https://rss.${domain}`;
|
||||
const apiVoteUrl = new URL('m/newsvote.ashx', rootUrl).href;
|
||||
|
||||
const title = '快科技';
|
||||
|
||||
const categories = {
|
||||
new: '最新',
|
||||
hot: '热门',
|
||||
zhibo: '直播',
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a path string into a query string.
|
||||
* @param {string} path - The path string separated by slashes, containing key-value pairs.
|
||||
* @returns {string} - The query string with key-value pairs separated by question marks and equal signs.
|
||||
*/
|
||||
const convertToQueryString = (path) => {
|
||||
const parts = path.split('/');
|
||||
const queryStringParams = [];
|
||||
|
||||
for (const [key, value] of parts.reduce((acc, part, index) => {
|
||||
if (index % 2 === 0) {
|
||||
acc.push([part]);
|
||||
} else {
|
||||
acc[acc.length - 1].push(part);
|
||||
}
|
||||
return acc;
|
||||
}, [])) {
|
||||
queryStringParams.push(`${key}=${value}`);
|
||||
}
|
||||
|
||||
return `?${queryStringParams.join('&')}`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves information from a given URL using a provided tryGet function.
|
||||
* @param {string} url - The URL to retrieve information from.
|
||||
* @param {function} tryGet - The tryGet function that handles the retrieval process.
|
||||
* @param {number|undefined} [range] - The index value of the range (optional).
|
||||
* @returns {Promise<Object>} - A promise that resolves to an object containing the retrieved information.
|
||||
*/
|
||||
const getInfo = (url, tryGet, range = undefined) =>
|
||||
tryGet(url, async () => {
|
||||
const { data: response } = await got(url);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const icon = new URL($('link[rel="apple-touch-icon-precomposed"]').prop('href'), rootUrl).href;
|
||||
const image = `https:${$('div.logo a img').prop('src')}`;
|
||||
const ranges = $('div.hottime a')
|
||||
.toArray()
|
||||
.map((a) => $(a).text());
|
||||
|
||||
return {
|
||||
title: `${title} - ${range !== undefined && ranges ? ranges[range] : $(`a[data-id="${url.split(/=/).pop()}"]`).text() || $('#newsEventSwitch a.cur').text()}`,
|
||||
link: url,
|
||||
description: $('meta[name="description"]').prop('content'),
|
||||
language: 'zh-cn',
|
||||
image,
|
||||
icon,
|
||||
logo: icon,
|
||||
subtitle: $('meta[name="keywords"]').prop('content'),
|
||||
author: title,
|
||||
allowEmpty: true,
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Process items asynchronously.
|
||||
*
|
||||
* @param {Array<Object>} items - The array of items to process.
|
||||
* @param {function} tryGet - The tryGet function that handles the retrieval process.
|
||||
* @returns {Promise<Array<Object>>} Returns a Promise that resolves to an array of processed items.
|
||||
*/
|
||||
const processItems = async (items, tryGet) =>
|
||||
await Promise.all(
|
||||
items.map((item) =>
|
||||
tryGet(`${domain}#${item.guid}`, async () => {
|
||||
const { data: detailResponse } = await got(`${rootUrl}/newsview/${item.guid}.html`);
|
||||
|
||||
const { data: voteResponse } = await got.post(apiVoteUrl, {
|
||||
json: {
|
||||
Tid: item.guid,
|
||||
},
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse);
|
||||
|
||||
item.title = content('div.news_t').text() || item.title;
|
||||
item.description = content('#content').html() ?? item.description;
|
||||
item.author = content('li.writer').text() || item.author;
|
||||
item.category = [
|
||||
...(item.category ?? []),
|
||||
...content('div.bqian1 a')
|
||||
.toArray()
|
||||
.map((c) => content(c).contents().last().text().trim()),
|
||||
].filter((c) => c);
|
||||
item.guid = `${domain}#${item.guid}`;
|
||||
item.pubDate = item.pubDate ?? timezone(parseDate(content('li.writer').next().text().trim(), 'YYYY年MM月DD日 HH:mm'), +8);
|
||||
item.upvotes = voteResponse.NewsSupport ? parseInt(voteResponse.NewsSupport, 10) : 0;
|
||||
item.downvotes = voteResponse.NewsOppose ? parseInt(voteResponse.NewsOppose, 10) : 0;
|
||||
item.comments = content('#tpinglun').text() ? parseInt(content('#tpinglun').text(), 10) : 0;
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
module.exports = {
|
||||
rootUrl,
|
||||
rootRSSUrl,
|
||||
title,
|
||||
categories,
|
||||
|
||||
convertToQueryString,
|
||||
getInfo,
|
||||
processItems,
|
||||
};
|
||||
@@ -3328,55 +3328,242 @@ column 为 third 时可选的 category:
|
||||
|
||||
## 快科技 {#kuai-ke-ji}
|
||||
|
||||
### 新闻 {#kuai-ke-ji-xin-wen}
|
||||
### 最新 {#kuai-ke-ji-zui-xin}
|
||||
|
||||
<Route author="nczitzk" example="/mydrivers" path="/mydrivers/:type?/:id?" paramsDesc={['类型,见下表,默认为最新', '编号,可在对应页面地址栏中找到']}>
|
||||
<Route author="kt286 nczitzk" example="/mydrivers/new" path="/mydrivers/new" radar="1" rssbud="1"/>
|
||||
|
||||
:::tip
|
||||
### 热门 {#kuai-ke-ji-re-men}
|
||||
|
||||
使用 **类型** 表中的两个参数时,编号应留空,如:**最新** 为 [`/mydrivers/new`](https://rsshub.app/mydrivers/new)
|
||||
<Route author="nczitzk" example="/mydrivers/hot" path="/mydrivers/hot" radar="1" rssbud="1"/>
|
||||
|
||||
使用 **编号** 表中的参数不应遗漏对应类型参数,如 **电脑** 为 [`/mydrivers/bcid/801`](https://rsshub.app/mydrivers/bcid/801)
|
||||
### 发布会 {#kuai-ke-ji-fa-bu-hui}
|
||||
|
||||
:::
|
||||
<Route author="nczitzk" example="/mydrivers/zhibo" path="/mydrivers/zhibo" radar="1" rssbud="1"/>
|
||||
|
||||
类型
|
||||
### 排行 {#kuai-ke-ji-pai-hang}
|
||||
|
||||
| 最新 | 热门 |
|
||||
| ---- | ---- |
|
||||
| new | hot |
|
||||
<Route author="nczitzk" example="/mydrivers/rank" path="/mydrivers/rank/:range?" paramsDesc={['时间范围,见下表,默认为24小时最热']} radar="1" rssbud="1">
|
||||
|
||||
编号
|
||||
| 24小时最热 | 本周最热 | 本月最热 |
|
||||
| ---------- | -------- | -------- |
|
||||
| 0 | 1 | 2 |
|
||||
|
||||
| 最新 | 最热 | 电脑 | 手机 | 汽车 | 业界 |
|
||||
| ------ | ------ | -------- | -------- | -------- | -------- |
|
||||
| ac/new | ac/hot | bcid/801 | bcid/802 | bcid/807 | bcid/803 |
|
||||
</Route>
|
||||
|
||||
| 科学 | 排行 | 评测 | 安卓 | 苹果 | CPU |
|
||||
| -------- | -------- | -------- | -------- | ------- | ------ |
|
||||
| tid/1000 | tid/1001 | tid/1002 | icid/121 | cid/201 | cid/13 |
|
||||
### 分类 {#kuai-ke-ji-fen-lei}
|
||||
|
||||
| 显卡 | 一图 | 阿里 | 微软 | 百度 | 影视 |
|
||||
| ------ | -------- | -------- | ------- | ------- | -------- |
|
||||
| cid/12 | tid/1003 | icid/270 | icid/90 | icid/67 | bcid/809 |
|
||||
<Route author="nczitzk" example="/mydrivers/bcid/801" path="/mydrivers/:category?" paramsDesc={['分类,见下表,默认为最新']} radar="1" rssbud="1">
|
||||
|
||||
| 游戏 | 路由器 | PS5 | Xbox | 华为 | OPPO |
|
||||
| -------- | ------ | --------- | -------- | -------- | -------- |
|
||||
| bcid/806 | cid/38 | icid/6950 | icid/194 | icid/136 | icid/148 |
|
||||
#### 板块 {#kuai-ke-ji-fen-lei-ban-kuai}
|
||||
|
||||
| 小米 | VIVO | 三星 | 魅族 | 一加 | 特斯拉 |
|
||||
| --------- | -------- | -------- | -------- | -------- | --------- |
|
||||
| icid/9355 | icid/288 | icid/154 | icid/140 | icid/385 | icid/1193 |
|
||||
| 电脑 | 手机 | 汽车 | 业界 | 游戏 |
|
||||
| -------- | -------- | -------- | -------- | -------- |
|
||||
| bcid/801 | bcid/802 | bcid/807 | bcid/803 | bcid/806 |
|
||||
|
||||
| 比亚迪 | 小鹏 | 蔚来 | 理想 | 奔驰 | 宝马 | 大众 |
|
||||
| -------- | --------- | --------- | ---------- | -------- | -------- | -------- |
|
||||
| icid/770 | icid/7259 | icid/7318 | icid/12947 | icid/429 | icid/461 | icid/481 |
|
||||
#### 话题 {#kuai-ke-ji-fen-lei-hua-ti}
|
||||
|
||||
| 科学 | 排行 | 评测 | 一图 |
|
||||
| -------- | -------- | -------- | -------- |
|
||||
| tid/1000 | tid/1001 | tid/1002 | tid/1003 |
|
||||
|
||||
#### 品牌 {#kuai-ke-ji-fen-lei-pin-pai}
|
||||
|
||||
| 安卓 | 阿里 | 微软 | 百度 | PS5 | Xbox | 华为 |
|
||||
| -------- | -------- | ------- | ------- | --------- | -------- | -------- |
|
||||
| icid/121 | icid/270 | icid/90 | icid/67 | icid/6950 | icid/194 | icid/136 |
|
||||
|
||||
| 小米 | VIVO | 三星 | 魅族 | 一加 | 比亚迪 | 小鹏 |
|
||||
| --------- | -------- | -------- | -------- | -------- | -------- | --------- |
|
||||
| icid/9355 | icid/288 | icid/154 | icid/140 | icid/385 | icid/770 | icid/7259 |
|
||||
|
||||
| 蔚来 | 理想 | 奔驰 | 宝马 | 大众 |
|
||||
| --------- | ---------- | -------- | -------- | -------- |
|
||||
| icid/7318 | icid/12947 | icid/429 | icid/461 | icid/481 |
|
||||
|
||||
<details>
|
||||
<summary>更多分类</summary>
|
||||
|
||||
| 电脑配件 | 手机之家 | 家用电器 | 网络设备 | 办公外设 | 游戏之家 |
|
||||
| -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| cid/2 | cid/3 | cid/4 | cid/5 | cid/6 | cid/7 |
|
||||
|
||||
| 电脑软件 | 业内动向 | 品牌整机 | 其它资讯 | 显卡 | CPU |
|
||||
| -------- | -------- | -------- | -------- | ------ | ------ |
|
||||
| cid/8 | cid/9 | cid/10 | cid/11 | cid/12 | cid/13 |
|
||||
|
||||
| 主板 | 内存 | 硬盘 | 机箱 | 电源 | 散热器 |
|
||||
| ------ | ------ | ------ | ------ | ------ | ------ |
|
||||
| cid/14 | cid/15 | cid/16 | cid/17 | cid/18 | cid/19 |
|
||||
|
||||
| 光驱 | 声卡 | 键鼠 | 音箱 | 手机厂商 | 手机配件 |
|
||||
| ------ | ------ | ------ | ------ | -------- | -------- |
|
||||
| cid/20 | cid/21 | cid/22 | cid/23 | cid/24 | cid/25 |
|
||||
|
||||
| PDA | MP3/MP4 | 摄像机 | 数码相机 | 摄像头 | 数码配件 |
|
||||
| ------ | ------- | ------ | -------- | ------ | -------- |
|
||||
| cid/26 | cid/27 | cid/29 | cid/30 | cid/31 | cid/32 |
|
||||
|
||||
| 电子书 | 导航产品 | 录音笔 | 交换机 | 路由器 | 防火墙 |
|
||||
| ------ | -------- | ------ | ------ | ------ | ------ |
|
||||
| cid/33 | cid/34 | cid/35 | cid/37 | cid/38 | cid/40 |
|
||||
|
||||
| 网卡 | 网络存储 | UPS | 打印机 | 复印机 | 复合机 |
|
||||
| ------ | -------- | ------ | ------ | ------ | ------ |
|
||||
| cid/41 | cid/43 | cid/44 | cid/45 | cid/46 | cid/47 |
|
||||
|
||||
| 投影仪 | 扫描仪 | 传真机 | 电脑游戏 | 主机游戏 | 游戏主机 |
|
||||
| ------ | ------ | ------ | -------- | -------- | -------- |
|
||||
| cid/48 | cid/49 | cid/51 | cid/52 | cid/53 | cid/54 |
|
||||
|
||||
| 掌机游戏 | 电脑驱动 | 桌面系统 | 视点人物 | 数据报告 | 科技前沿 |
|
||||
| -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| cid/55 | cid/57 | cid/58 | cid/62 | cid/63 | cid/65 |
|
||||
|
||||
| 笔记本 | 台式机 | 服务器 | 一体机 | 其他 | PC硬件 |
|
||||
| ------ | ------ | ------ | ------ | ------ | ------ |
|
||||
| cid/66 | cid/67 | cid/68 | cid/69 | cid/73 | cid/74 |
|
||||
|
||||
| 时尚数码 | 软件驱动 | 显示器 | 音箱耳机 | 投影机 | 便携机 |
|
||||
| -------- | -------- | ------ | -------- | ------- | ------- |
|
||||
| cid/78 | cid/79 | cid/80 | cid/92 | cid/100 | cid/108 |
|
||||
|
||||
| 手机 | MP3 | MP4 | 闪存盘 | DV摄像机 | U盘 |
|
||||
| ------- | ------- | ------- | ------- | -------- | ------- |
|
||||
| cid/109 | cid/112 | cid/113 | cid/114 | cid/115 | cid/116 |
|
||||
|
||||
| GPS | 移动硬盘 | 操作系统 | 驱动 | 软件 | 软件更新 |
|
||||
| ------- | -------- | -------- | ------- | ------- | -------- |
|
||||
| cid/117 | cid/119 | cid/120 | cid/121 | cid/122 | cid/123 |
|
||||
|
||||
| 新软推荐 | 业界动态 | 软件评测 | 软件技巧 | 游戏相关 | 驱动研究 |
|
||||
| -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| cid/124 | cid/125 | cid/126 | cid/127 | cid/128 | cid/130 |
|
||||
|
||||
| 游戏试玩 | 硬件学堂 | 实用技巧 | 新软体验 | 资讯教程 | 软件横评 |
|
||||
| -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| cid/131 | cid/132 | cid/133 | cid/134 | cid/135 | cid/136 |
|
||||
|
||||
| Windows | Mac | Linux | 其它 | 使用技巧 | 深入研究 |
|
||||
| ------- | ------- | ------- | ------- | -------- | -------- |
|
||||
| cid/137 | cid/138 | cid/139 | cid/140 | cid/141 | cid/142 |
|
||||
|
||||
| 游戏机 | 显示 | 存储 | 音频 | 外设 | 数码 |
|
||||
| ------- | ------- | ------- | ------- | ------- | ------- |
|
||||
| cid/144 | cid/145 | cid/146 | cid/147 | cid/148 | cid/151 |
|
||||
|
||||
| 网络 | 办公 | 维修 | 安全 | 聊天 | 影音 |
|
||||
| ------- | ------- | ------- | ------- | ------- | ------- |
|
||||
| cid/152 | cid/154 | cid/155 | cid/156 | cid/157 | cid/158 |
|
||||
|
||||
| 国内 | 国外 | 办公应用 | 设计创意 | 基础知识 | 程序 |
|
||||
| ------- | ------- | -------- | -------- | -------- | ------- |
|
||||
| cid/159 | cid/160 | cid/161 | cid/162 | cid/163 | cid/164 |
|
||||
|
||||
| 其他硬件 | 电视卡/盒 | 游戏体验 | 平板电视 | 企业动态 | 天文航天 |
|
||||
| -------- | --------- | -------- | -------- | -------- | -------- |
|
||||
| cid/166 | cid/170 | cid/172 | cid/173 | cid/174 | cid/175 |
|
||||
|
||||
| MID设备 | 数码相框 | 耳机 | 通讯运营商 | 电视盒 | 线材线缆 |
|
||||
| ------- | -------- | ------- | ---------- | ------- | -------- |
|
||||
| cid/176 | cid/177 | cid/179 | cid/180 | cid/182 | cid/183 |
|
||||
|
||||
| 小家电 | 网络游戏 | 行情信息 | 科学动态 | 生物世界 | 历史考古 |
|
||||
| ------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| cid/184 | cid/186 | cid/188 | cid/192 | cid/193 | cid/194 |
|
||||
|
||||
| 生科医学 | 地理自然 | 工程建筑 | 苹果手机 | 谷歌Android | 塞班手机 |
|
||||
| -------- | -------- | -------- | -------- | ----------- | -------- |
|
||||
| cid/195 | cid/196 | cid/197 | cid/201 | cid/202 | cid/203 |
|
||||
|
||||
| 黑莓手机 | 微软手机 | 移动处理器 | 山寨机 | 手机游戏 | 安卓应用 |
|
||||
| -------- | -------- | ---------- | ------- | -------- | -------- |
|
||||
| cid/204 | cid/205 | cid/206 | cid/208 | cid/209 | cid/210 |
|
||||
|
||||
| 娱乐生活 | 明星全接触 | 电影影讯 | 电视节目 | 音乐戏曲 | 国际风云 |
|
||||
| -------- | ---------- | -------- | -------- | -------- | -------- |
|
||||
| cid/212 | cid/213 | cid/214 | cid/215 | cid/216 | cid/217 |
|
||||
|
||||
| 国内传真 | 社会民生 | 生活百态 | 医药健康 | 家居尚品 | 星座旅游 |
|
||||
| -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| cid/218 | cid/219 | cid/220 | cid/221 | cid/222 | cid/223 |
|
||||
|
||||
| 评论分析 | 体育竞技 | IT八卦 | 科技动态 | 游戏动态 | 手机系统 |
|
||||
| -------- | -------- | ------- | -------- | -------- | -------- |
|
||||
| cid/224 | cid/225 | cid/226 | cid/227 | cid/228 | cid/232 |
|
||||
|
||||
| 智能设备 | 生活电器 | 汽车相关 | 飞机航空 | 手机周边 | 网络运营商 |
|
||||
| -------- | -------- | -------- | -------- | -------- | ---------- |
|
||||
| cid/233 | cid/234 | cid/235 | cid/236 | cid/237 | cid/238 |
|
||||
|
||||
| 平板电脑 | 苹果iPad | 安卓平板 | Windows平板 | 创业路上 | 网友热议 |
|
||||
| -------- | -------- | -------- | ----------- | -------- | -------- |
|
||||
| cid/239 | cid/240 | cid/241 | cid/242 | cid/243 | cid/244 |
|
||||
|
||||
| IT圈 | 数码周边 | 智能手环 | 智能眼镜 | 智能手表 | iOS应用 |
|
||||
| ------- | -------- | -------- | -------- | -------- | ------- |
|
||||
| cid/246 | cid/247 | cid/248 | cid/249 | cid/250 | cid/251 |
|
||||
|
||||
| 壁纸主题 | 游戏厂商 | 数理化学 | 科普知识 | 奇趣探险 | 汽车世界 |
|
||||
| -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| cid/252 | cid/253 | cid/254 | cid/255 | cid/256 | cid/257 |
|
||||
|
||||
| 传统汽车 | 电动汽车 | 新能源汽车 | 无人驾驶汽车 | 车载系统 | 车载配件 |
|
||||
| -------- | -------- | ---------- | ------------ | -------- | -------- |
|
||||
| cid/258 | cid/259 | cid/260 | cid/261 | cid/262 | cid/263 |
|
||||
|
||||
| 汽车厂商 | 影音动漫 | 精彩影视 | 电影动画 | 艺术设计 | 摄影达人 |
|
||||
| -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| cid/264 | cid/265 | cid/266 | cid/267 | cid/269 | cid/270 |
|
||||
|
||||
| 固件 | 样张赏析 | 创意摄影 | WP应用 | 教育未来 | 安卓手机 |
|
||||
| ------- | -------- | -------- | ------- | -------- | -------- |
|
||||
| cid/272 | cid/273 | cid/274 | cid/284 | cid/285 | cid/288 |
|
||||
|
||||
| 智能穿戴 | 移动应用 | 电子竞技 | 游戏八卦 | 游戏评测 | 生活百科 |
|
||||
| -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| cid/290 | cid/292 | cid/297 | cid/298 | cid/299 | cid/301 |
|
||||
|
||||
| 智能家居 | 智能插座 | 智能摄像头 | 智能路由器 | 智能体重秤 | 智能血压计 |
|
||||
| -------- | -------- | ---------- | ---------- | ---------- | ---------- |
|
||||
| cid/302 | cid/303 | cid/304 | cid/305 | cid/306 | cid/307 |
|
||||
|
||||
| 空气净化器 | 智能净水器 | 电动两轮车 | 公司财报 | 智能行车记录仪 | 网络影视 |
|
||||
| ---------- | ---------- | ---------- | -------- | -------------- | -------- |
|
||||
| cid/308 | cid/309 | cid/310 | cid/311 | cid/312 | cid/313 |
|
||||
|
||||
| 多轴无人机 | 摩托车 | 自行车 | 共享经济 | 生活周边 | 网络安全 |
|
||||
| ---------- | ------- | ------- | -------- | -------- | -------- |
|
||||
| cid/314 | cid/316 | cid/317 | cid/320 | cid/321 | cid/322 |
|
||||
|
||||
| 考勤机 | 网络红人 | 火车高铁 | 机器人 | 其他网络 | 快递物流 |
|
||||
| ------- | -------- | -------- | ------- | -------- | -------- |
|
||||
| cid/323 | cid/324 | cid/325 | cid/326 | cid/327 | cid/328 |
|
||||
|
||||
| 科技资讯 | 好货推荐 | 日常用品 | 餐饮零食 | 化妆品 | 运动健康 |
|
||||
| -------- | -------- | -------- | -------- | ------- | -------- |
|
||||
| cid/329 | cid/334 | cid/335 | cid/336 | cid/339 | cid/340 |
|
||||
|
||||
| 酒水饮料 | 个人洗护 | 电子产品 | 服装鞋帽 | 会员卡 | 用户投稿 |
|
||||
| -------- | -------- | -------- | -------- | ------- | -------- |
|
||||
| cid/341 | cid/342 | cid/343 | cid/345 | cid/346 | cid/351 |
|
||||
|
||||
| APP投稿 | PC投稿 | 视频快讯 | 新品开箱 | 技巧教程 | 科技快讯 |
|
||||
| ------- | ------- | -------- | -------- | -------- | -------- |
|
||||
| cid/352 | cid/353 | cid/354 | cid/355 | cid/356 | cid/357 |
|
||||
|
||||
| 产品评测 | 人物专访 | 会议活动 | 数码影音 | 数码影像 | 游戏周边 |
|
||||
| -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| cid/358 | cid/359 | cid/360 | cid/361 | cid/362 | cid/368 |
|
||||
|
||||
| 汽车周边 | 个人交通 | 其他交通 |
|
||||
| -------- | -------- | -------- |
|
||||
| cid/369 | cid/370 | cid/371 |
|
||||
|
||||
</details>
|
||||
|
||||
</Route>
|
||||
|
||||
### 最新新闻 {#kuai-ke-ji-zui-xin-xin-wen}
|
||||
|
||||
<Route author="kt286" example="/kkj/news" path="/kkj/news"/>
|
||||
|
||||
## 快媒体 {#kuai-mei-ti}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user