mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 23:34:38 +08:00
fix(route): zaker wrong link (#8776)
This commit is contained in:
@@ -1120,17 +1120,13 @@ Supported sub-sites:
|
||||
|
||||
## ZAKER
|
||||
|
||||
### source
|
||||
### 分类
|
||||
|
||||
<Route author="LogicJake" example="/zaker/source/12291" path="/zaker/source/:id" :paramsDesc="['source id,可在 URL 中找到']"/>
|
||||
|
||||
### channel
|
||||
|
||||
<Route author="kt286" example="/zaker/channel/13" path="/zaker/source/:id" :paramsDesc="['channel id,可在 URL 中找到']"/>
|
||||
<Route author="LogicJake kt286 TonyRL" example="/zaker/channel/13" path="/zaker/channel/:id?" :paramsDesc="['channel id,可在 URL 中找到,默认为 1']"/>
|
||||
|
||||
### 精读
|
||||
|
||||
<Route author="AlexdanerZe" example="/zaker/focusread" path="/zaker/focusread" />
|
||||
<Route author="AlexdanerZe TonyRL" example="/zaker/focusread" path="/zaker/focusread" />
|
||||
|
||||
## 爱范儿 ifanr
|
||||
|
||||
|
||||
@@ -1606,9 +1606,9 @@ router.get('/checkee/:dispdate', lazyloadRouteHandler('./routes/checkee/index'))
|
||||
// 艾瑞
|
||||
router.get('/iresearch/report', lazyloadRouteHandler('./routes/iresearch/report'));
|
||||
|
||||
// ZAKER
|
||||
router.get('/zaker/:type/:id', lazyloadRouteHandler('./routes/zaker/source'));
|
||||
router.get('/zaker/focusread', lazyloadRouteHandler('./routes/zaker/focusread'));
|
||||
// ZAKER migrated to v2
|
||||
// router.get('/zaker/:type/:id', lazyloadRouteHandler('./routes/zaker/source'));
|
||||
// router.get('/zaker/focusread', lazyloadRouteHandler('./routes/zaker/focusread'));
|
||||
|
||||
// Matters
|
||||
router.get('/matters/latest/:type?', lazyloadRouteHandler('./routes/matters/latest'));
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseRelativeDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = `http://www.myzaker.com/?pos=selected_article`;
|
||||
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
const title = $('.main-title').text();
|
||||
|
||||
const list = $('div.content-block')
|
||||
.slice(0, 10)
|
||||
.map(function () {
|
||||
const info = {
|
||||
title: $(this).find('.article-title').text(),
|
||||
link: $(this).find('.article-wrap > a').attr('href'),
|
||||
};
|
||||
return info;
|
||||
})
|
||||
.get();
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map(async (info) => {
|
||||
const title = info.title;
|
||||
const itemUrl = 'http:' + info.link;
|
||||
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const response = await got({
|
||||
url: itemUrl,
|
||||
method: 'get',
|
||||
headers: {
|
||||
Referer: link,
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const description = $('div.article_content div').html() || '原文已被删除';
|
||||
|
||||
const date = $('span.time').text();
|
||||
|
||||
const single = {
|
||||
title,
|
||||
link: itemUrl,
|
||||
description,
|
||||
pubDate: timezone(parseRelativeDate(date), +8),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
const outfilter = out.filter((t) => t.description !== '原文已被删除');
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${title}-ZAKER精读新闻`,
|
||||
link,
|
||||
item: outfilter,
|
||||
};
|
||||
};
|
||||
@@ -1,66 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseRelativeDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type || 'source';
|
||||
const id = ctx.params.id;
|
||||
const link = `http://www.myzaker.com/${type}/${id}`;
|
||||
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
const title = $('.main-title').text();
|
||||
|
||||
const list = $('div.content-block')
|
||||
.slice(0, 10)
|
||||
.map(function () {
|
||||
const info = {
|
||||
title: $(this).find('.article-title').text(),
|
||||
link: $(this).find('.article-wrap > a').attr('href'),
|
||||
};
|
||||
return info;
|
||||
})
|
||||
.get();
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map(async (info) => {
|
||||
const title = info.title;
|
||||
const itemUrl = 'http:' + info.link;
|
||||
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const response = await got({
|
||||
url: itemUrl,
|
||||
method: 'get',
|
||||
headers: {
|
||||
Referer: link,
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const description = $('div.article_content div').html() || '原文已被删除';
|
||||
|
||||
const date = $('span.time').text();
|
||||
|
||||
const single = {
|
||||
title,
|
||||
link: itemUrl,
|
||||
description,
|
||||
pubDate: timezone(parseRelativeDate(date), +8),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${title}-ZAKER新闻`,
|
||||
link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
65
lib/v2/zaker/index.js
Normal file
65
lib/v2/zaker/index.js
Normal file
@@ -0,0 +1,65 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseRelativeDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type ?? 'channel';
|
||||
const id = ctx.params.id ?? 1;
|
||||
const rootUrl = 'http://www.myzaker.com';
|
||||
const link = type === 'focusread' ? `${rootUrl}/?pos=selected_article` : `${rootUrl}/${type}/${id}`;
|
||||
|
||||
const response = await got({
|
||||
url: link,
|
||||
headers: {
|
||||
Referer: rootUrl,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const feedTitle = $('head title').text();
|
||||
|
||||
let items = $('div.content-block')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('.article-title').text(),
|
||||
link: 'http:' + item.find('.article-wrap > a').attr('href').replace('http://', ''),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const response = await got({
|
||||
url: item.link,
|
||||
headers: {
|
||||
Referer: link,
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
item.description = $('div.article_content div').html() ?? '原文已被删除';
|
||||
item.author = $('a.article-auther.line').text();
|
||||
item.category = $('.lebel-list')
|
||||
.find('a')
|
||||
.toArray()
|
||||
.map((item) => $(item).text());
|
||||
const date = $('span.time').text() ?? undefined;
|
||||
if (date) {
|
||||
item.pubDate = timezone(parseRelativeDate(date), +8);
|
||||
}
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: type === 'focusread' ? 'ZAKER 精读新闻' : feedTitle,
|
||||
link,
|
||||
item: items.filter((t) => t.description !== '原文已被删除'),
|
||||
};
|
||||
};
|
||||
3
lib/v2/zaker/maintainer.js
Normal file
3
lib/v2/zaker/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:type/:id?': ['LogicJake', 'kt286', 'AlexdanerZe', 'TonyRL'],
|
||||
};
|
||||
19
lib/v2/zaker/radar.js
Normal file
19
lib/v2/zaker/radar.js
Normal file
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'myzaker.com': {
|
||||
_name: 'ZAKER',
|
||||
'.': [
|
||||
{
|
||||
title: '分类',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#zaker',
|
||||
source: ['/:type/:id'],
|
||||
target: '/zaker/:type/:id',
|
||||
},
|
||||
{
|
||||
title: '精读',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#zaker',
|
||||
source: ['/'],
|
||||
target: '/zaker/focusread',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
3
lib/v2/zaker/router.js
Normal file
3
lib/v2/zaker/router.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/:type/:id?', require('./index'));
|
||||
};
|
||||
Reference in New Issue
Block a user