fix(route): /163/dy2/:id pic shows correctly (#14955)

This commit is contained in:
lyqluis
2024-03-25 22:57:46 +08:00
committed by GitHub
parent 970ad011d0
commit 6e75de7946
2 changed files with 6 additions and 4 deletions
+4 -3
View File
@@ -11,7 +11,7 @@ export const route: Route = {
path: '/dy2/:id',
categories: ['new-media'],
example: '/163/dy2/T1555591616739',
parameters: { id: 'id,该网易号主页网址最后一项html的文件名' },
parameters: { id: 'id,该网易号主页网址最后一项 html 的文件名' },
features: {
requireConfig: false,
requirePuppeteer: false,
@@ -21,7 +21,7 @@ export const route: Route = {
supportScihub: false,
},
name: '网易号(通用)',
maintainers: ['mjysci'],
maintainers: ['mjysci', 'lyqluis'],
handler,
description: `优先使用方法一,若是网易号搜索页面搜不到的小众网易号(文章页面不含\`data-wemediaid\`)则可使用此法。
触发反爬会只抓取到标题,建议自建。`,
@@ -43,11 +43,12 @@ async function handler(ctx) {
.toArray()
.map((item) => {
item = $(item);
const itemImg = item.find('a.img img');
return {
title: item.find('h4 a').text(),
link: item.find('a').first().attr('href'),
pubDate: timezone(parseDate(item.find('.time').text()), 8),
imgsrc: item.find('a img').attr('src'),
imgsrc: itemImg.attr('src') ?? itemImg.attr('_src'),
};
});
+2 -1
View File
@@ -26,8 +26,9 @@ const parseDyArticle = (charset, item, tryGet) =>
}
});
const imgUrl = new URL(item.imgsrc);
item.description = art(path.join(__dirname, 'templates/dy.art'), {
imgsrc: item.imgsrc?.split('?')[0],
imgsrc: imgUrl.searchParams.get('url'),
postBody: $('.post_body').html(),
});