From d5d3b6abff442e101b2a310ce68f85b388aacec7 Mon Sep 17 00:00:00 2001 From: Cloud Date: Sun, 11 Aug 2019 00:45:13 +0800 Subject: [PATCH] fix: dekudeals (#2814) --- lib/routes/dekudeals/index.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/routes/dekudeals/index.js b/lib/routes/dekudeals/index.js index 3f0929a1b6..8e6824a997 100644 --- a/lib/routes/dekudeals/index.js +++ b/lib/routes/dekudeals/index.js @@ -2,7 +2,6 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const url = require('url'); -const host = 'https://www.dekudeals.com/'; module.exports = async (ctx) => { const type = ctx.params.type; const link = url.resolve(host, type); @@ -10,18 +9,20 @@ module.exports = async (ctx) => { const response = await got.get(link); const $ = cheerio.load(response.data); - const title = $('body > main > div:nth-child(1) > div > h3').text(); - const list = $('body > main > div:nth-child(2) > div > table > tbody > tr'); + const title = $('#search-title').text(); + const list = $('.search-main > .item-grid2 > div'); + const host = 'https://www.dekudeals.com/'; const out = await Promise.all( list .map(async (index, item) => { item = $(item); - const title = item.find('td:nth-child(2) > a').text(); - const link = url.resolve(host, item.find('td:nth-child(2) > a').attr('href')); - const img = item.find('td.image img').attr('src'); - const price = item.find('td:nth-child(3)').html(); - const description = `` + '
' + price; + const title = item.find('.name').text(); + const link = url.resolve(host, item.find('.main-link').attr('href')); + const img = item.find('.main-link img').attr('src'); + const price = item.find('strong').html(); + const oldprice = item.find('s.text-muted').html(); + const description = `
${oldprice}
${price}`; const single = { title,