Showing
1 changed file
with
7 additions
and
4 deletions
@@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | 8 | ||
9 | const _ = require('lodash'); | 9 | const _ = require('lodash'); |
10 | +const cheerio = require('cheerio'); | ||
10 | 11 | ||
11 | const helpers = global.yoho.helpers; | 12 | const helpers = global.yoho.helpers; |
12 | 13 | ||
@@ -295,11 +296,13 @@ const getGlobalProductDetailData = (skn, channelNum, channel) => { | @@ -295,11 +296,13 @@ const getGlobalProductDetailData = (skn, channelNum, channel) => { | ||
295 | } | 296 | } |
296 | 297 | ||
297 | if (result.html && !_.get(result.html, 'code', '')) { | 298 | if (result.html && !_.get(result.html, 'code', '')) { |
298 | - let regContent = /<body[^>]*>([\s\S]*)<\/body>/.exec(result.html); | 299 | + let $ = cheerio.load(result.html); |
299 | 300 | ||
300 | - if (regContent && regContent.length) { | ||
301 | - html = regContent[1] || ''; | ||
302 | - html = html.replace(/<script.*?>.*?<\/script>/ig, ''); | 301 | + $('script').remove(); |
302 | + html = $('body').html(); | ||
303 | + | ||
304 | + if (html) { | ||
305 | + html = html.replace(/http:/ig, ''); | ||
303 | } | 306 | } |
304 | } | 307 | } |
305 | 308 |
-
Please register or login to post a comment