fix(route): sohu_mp can not get author's link and refactor to V2 (#9311)
* fix(route): sohu_mp can not get author's link and refactor to V2 * fix: pubDate * fix: remove unused timezone Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
This commit is contained in:
parent
5b5e8ce1fa
commit
43f1d1813d
|
|
@ -2071,9 +2071,6 @@ router.get('/nciae/xsxx', lazyloadRouteHandler('./routes/universities/nciae/xsxx
|
|||
// cfan
|
||||
router.get('/cfan/news', lazyloadRouteHandler('./routes/cfan/news'));
|
||||
|
||||
// 搜狐 - 搜狐号
|
||||
router.get('/sohu/mp/:id', lazyloadRouteHandler('./routes/sohu/mp'));
|
||||
|
||||
// 腾讯企鹅号
|
||||
router.get('/tencent/news/author/:mid', lazyloadRouteHandler('./routes/tencent/news/author'));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/mp/:id': ['HenryQW'],
|
||||
};
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const date = require('@/utils/date');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
const authorArticleAPI = `https://v2.sohu.com/author-page-api/author-articles/pc/${id}`;
|
||||
|
||||
const response = await got.get(`https://v2.sohu.com/author-page-api/author-articles/pc/${id}`);
|
||||
|
||||
const response = await got.get(authorArticleAPI);
|
||||
const list = response.data.data.pcArticleVOS.splice(0, 10);
|
||||
let author, link;
|
||||
|
||||
|
|
@ -23,9 +23,10 @@ module.exports = async (ctx) => {
|
|||
const $ = cheerio.load(response);
|
||||
|
||||
if (!author) {
|
||||
const meta = $('#article-container h4 > a');
|
||||
author = meta.text();
|
||||
link = meta.attr('href').split('==')[0];
|
||||
const meta = $('span[data-role="original-link"]');
|
||||
author = meta.find('a').text();
|
||||
// can't get author's link on server, so use the RSSHub link
|
||||
// link = meta.attr('href').split('==')[0];
|
||||
}
|
||||
|
||||
const article = $('#mp-editor');
|
||||
|
|
@ -38,11 +39,11 @@ module.exports = async (ctx) => {
|
|||
title: e.title,
|
||||
link: e.link,
|
||||
description: article.html(),
|
||||
pubDate: date(e.publicTimeStr, 8),
|
||||
pubDate: parseDate(e.publicTime),
|
||||
author,
|
||||
};
|
||||
|
||||
return Promise.resolve(single);
|
||||
return single;
|
||||
})
|
||||
);
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'sohu.com': {
|
||||
_name: '搜狐',
|
||||
'.': [
|
||||
{
|
||||
title: '搜狐号',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#sou-hu-hao',
|
||||
source: ['/a/:id'],
|
||||
target: (params) => `/sohu/mp/${params.id.split('_')[1]}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/mp/:id', require('./mp'));
|
||||
};
|
||||
Loading…
Reference in New Issue