From 1d151ebf6f009534b8f46e02ada1d6063ea3c0c0 Mon Sep 17 00:00:00 2001 From: cc789461 <62095874+cc789461@users.noreply.github.com> Date: Wed, 18 Mar 2020 10:37:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=A8=A1=E5=9E=8B=E7=BD=91=20(#4264)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/moxingnet/index.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/routes/moxingnet/index.js b/lib/routes/moxingnet/index.js index e94ebdd9e..d55c9aae6 100644 --- a/lib/routes/moxingnet/index.js +++ b/lib/routes/moxingnet/index.js @@ -11,7 +11,15 @@ module.exports = async (ctx) => { }); const data = iconv.decode(response.data, 'gb2312'); const $ = cheerio.load(data); - const list = $('ul.text_list.text_list_f14 li').get(); + const list = $('ul.text_list.text_list_f14 li') + .get() + .map(function(item) { + const $ = cheerio.load(item); + return baseUrl + $('a').attr('href'); + }) + .filter(function(link) { + return !link.includes('taobao'); + }); const ProcessLink = async (link) => { const response = await got({ @@ -32,26 +40,22 @@ module.exports = async (ctx) => { desc += next_page.desc; } return { + title: $('title').text(), desc: desc, }; }; const out = await Promise.all( - list.map(async (item) => { - const $ = cheerio.load(item); - const $a = $('a'); - const link = baseUrl + $a.attr('href'); + list.map(async (link) => { const cache = await ctx.cache.get(link); if (cache) { return Promise.resolve(JSON.parse(cache)); } const feed = await ProcessLink(link); - const description = feed.desc; - const single = { - title: $a.text(), - description, + title: feed.title, + description: feed.desc, link: link, }; ctx.cache.set(link, JSON.stringify(single));