fix: wasi url (#2314)

This commit is contained in:
凉凉
2019-06-04 16:27:33 +08:00
committed by DIYgod
parent c855ceee58
commit 218c06f96c

View File

@@ -2,11 +2,12 @@ const got = require('@/utils/got');
const cheerio = require('cheerio'); const cheerio = require('cheerio');
module.exports = async (ctx) => { module.exports = async (ctx) => {
const id = ctx.params.id; const { id } = ctx.params;
const url = `https://wx.qnmlgb.tech/authors/${id}`;
const response = await got({ const response = await got({
method: 'get', method: 'get',
url: `https://wx.qnmlgb.tech/authors/${id}`, url,
}); });
const $ = cheerio.load(response.data); const $ = cheerio.load(response.data);
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
title: `${$('#spider > div:nth-child(1) > div:nth-child(1)') title: `${$('#spider > div:nth-child(1) > div:nth-child(1)')
.text() .text()
.trim()}微信公众号`, .trim()}微信公众号`,
link: `https://w.qnmlgb.tech/authors/${id}/`, link: url,
description: $('#spider > div:nth-child(2)') description: $('#spider > div:nth-child(2)')
.text() .text()
.trim(), .trim(),
@@ -25,11 +26,14 @@ module.exports = async (ctx) => {
list list
.map((i, ele) => { .map((i, ele) => {
const $ = cheerio.load(ele); const $ = cheerio.load(ele);
const link = $('a').attr('href');
return { return {
title: $('.pretty') title: $('.pretty')
.text() .text()
.trim(), .trim(),
link: $('a').attr('href'), link: `https://wx.qnmlgb.tech${link}`,
guid: link,
}; };
}) })
.get(), .get(),