This commit is contained in:
sanmmmm 2019-08-26 11:00:52 +08:00 committed by DIYgod
parent d5a4f66619
commit 4e3d3685db
1 changed files with 7 additions and 6 deletions

View File

@ -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}`, `<img src=""${imgUrl}/>`].join('<br/>'),
};
@ -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,
};