fix: dekudeals (#2814)

This commit is contained in:
Cloud
2019-08-11 00:45:13 +08:00
committed by DIYgod
parent 0a2b43fd42
commit d5d3b6abff
+9 -8
View File
@@ -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 = `<img referrerpolicy="no-referrer" src="${img}">` + '<br>' + 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 = `<img referrerpolicy="no-referrer" src="${img}"><br><s>${oldprice}</s><br>${price}`;
const single = {
title,