From 4e3d3685db4643242e6e478a21a824a3fb06decb Mon Sep 17 00:00:00 2001 From: sanmmmm Date: Mon, 26 Aug 2019 11:00:52 +0800 Subject: [PATCH] fix: hpoi (#2934) --- lib/routes/hpoi/info.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/routes/hpoi/info.js b/lib/routes/hpoi/info.js index 244126c49..c2cd6f9d2 100644 --- a/lib/routes/hpoi/info.js +++ b/lib/routes/hpoi/info.js @@ -4,7 +4,8 @@ const FormData = require('form-data'); module.exports = async (ctx) => { const { type = 'all' } = ctx.params; - const reqUrl = 'https://www.hpoi.net/user/home/ajax'; + const baseUrl = 'https://www.hpoi.net'; + const reqUrl = `${baseUrl}/user/home/ajax`; const formData = new FormData(); Object.entries({ page: 1, @@ -20,7 +21,7 @@ module.exports = async (ctx) => { .map((_, ele) => { const $item = cheerio.load(ele); const leftNode = $item('.overlay-container'); - const link = leftNode + const relativeLink = leftNode .find('a') .first() .attr('href'); @@ -29,15 +30,15 @@ module.exports = async (ctx) => { .first() .text(); const imgUrl = leftNode - .find('.img') + .find('img') .first() - .attr('href'); + .attr('src'); const rightNode = $item('.home-info-content'); const infoType = rightNode.find('.user-name').contents()[0].data; const infoTitle = rightNode.find('.user-content').text(); return { title: infoTitle, - link, + link: `${baseUrl}/${relativeLink}`, category: infoType, description: [`类型:${typeName}`, infoTitle, `更新内容: ${infoType}`, ``].join('
'), }; @@ -52,7 +53,7 @@ module.exports = async (ctx) => { const title = `手办维基 - 情报 - ${typeToLabel[type]}`; ctx.state.data = { title, - link: `https://www.hpoi.net/user/home?type=info&catType=${type}`, + link: `${baseUrl}/user/home?type=info&catType=${type}`, description: title, item: items, };