Authored by 毕凯

Merge branch 'hotfix/cheerio' into 'release/6.3'

cheerio-data-type



See merge request !1173
const cheerio = require('cheerio');
const _ = require('lodash');
module.exports = {
/**
... ... @@ -99,6 +100,8 @@ module.exports = {
*/
process(html = '', prefix = 0) {
html = _.isString(html) ? html : '';
let $ = cheerio.load(html, {
decodeEntities: false
});
... ...
... ... @@ -9,6 +9,8 @@ const util = {
return html;
}
html = _.isString(html) ? html : '';
let $ = cheerio.load(html, {decodeEntities: false});
_.each($('p'), (item) => {
... ... @@ -35,6 +37,8 @@ const util = {
return html;
}
html = _.isString(html) ? html : '';
let $ = cheerio.load(html, {decodeEntities: false});
$('a').removeAttr('style').not('.a-anchor').attr('href', 'javascript:void(0);').css({cursor: 'text'});// eslint-disable-line
... ... @@ -52,6 +56,8 @@ const util = {
return html;
}
html = _.isString(html) ? html : '';
let $ = cheerio.load(html, {decodeEntities: false});
_.each($('img').slice(0, num), item => {
... ...
... ... @@ -92,7 +92,7 @@ exports.gethtml = (param) => {
return globalapi.get('product/api/v1/detail/gethtml', param, {
cache: true
}).then((result) => {
result = result || '';
result = _.isString(result) ? result : '';
result = $.load(result);
result = result('.good-detail-page');
... ...
... ... @@ -353,7 +353,7 @@ module.exports = class extends global.yoho.BaseModel {
},
param: {cache: true}
}).then(result => {
result = result || '';
result = _.isString(result) ? result : '';
result = $.load(result);
result = result('#productDesc');
... ...
... ... @@ -5,6 +5,7 @@
*/
'use strict';
const _ = require('lodash');
const $ = require('cheerio');
const helpers = global.yoho.helpers;
... ... @@ -35,6 +36,8 @@ module.exports = class extends global.yoho.BaseModel {
return '';
}
result = _.isString(result) ? result : '';
let goodsContainer = $.load(result)('#shop-goods-container');
let goodThumb = goodsContainer.find('.good-thumb');
... ...