Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function requestParseSearchItems ({requestOptions, xpath}) {
try {
const rsp = await request(requestOptions)
// 用htmlparser2转换一次再解析
let outerHTML = htmlparser2.DomUtils.getOuterHTML(htmlparser2.parseDOM(rsp))
const document = domParser.parseFromString(outerHTML)
return {items: parseDocument(document, xpath)}
} catch (e) {
console.error('解析失败', e)
return {err: e}
}
}
let extendBlock = extensions.find(node => node.attribs[options.EXT_POINT_REF_ATTR] === extPoint.attribs[options.EXT_POINT_NAME_ATTR]);
// If a extend block matching the extension point was found, replace the point's content with the extend block's
if (extendBlock) {
extPoint.children = extendBlock.children;
// Change extension point tag to a template tag
extPoint.name = 'template';
delete extPoint.attribs[options.EXT_POINT_NAME_ATTR];
}
});
// Resolve promise with the new generated SFC
resolve({
source: `<template>
${htmlparser.DomUtils.getOuterHTML(baseDom)}
</template>
${descriptorToHTML(currentDesc)}`,
ancestorsPaths
});
} catch (e) {
reject(e)
}
}, e => {
reject(e)
function innerHTML(dom) {
return htmlparser.DomUtils.getOuterHTML(dom, {
xmlMode: true
});
}
HtmlFile.prototype.webSrc = function(){
//transform the internal html sturcture into websource only when it's requested
var webSourceHtml = stripElements(this.parsedHtml, true);
//and for now... just assume this is a full html document
//this basically just adds the required css and js to the head
//also set the index attribute
var first = htmlparser.DomUtils.findOne(function() {return true}, webSourceHtml);
htmlparser.DomUtils.appendChild(first, {
type: 'script',
name: 'script',
attribs: {language: 'javascript'},
children: [{
data: HtmlFile.injectedJS,
type: 'text'
}]
});
htmlparser.DomUtils.appendChild(first, {
type: 'style',
name: 'style',
children: [{
data: HtmlFile.injectedCSS,
type: 'text'
'use strict';
var InvalidFormatError = require('./error').InvalidFormatError;
var Promise = Promise || require('es6-promise').Promise;
var htmlparser2 = require('htmlparser2');
var DomHandler = htmlparser2.DomHandler;
var Parser = htmlparser2.Parser;
var DomUtils = htmlparser2.DomUtils;
var includes = require('array-includes');
var parseFloatWithComma = require('./parse-float-with-comma');
var keysStringToFloat = [
'ratingCount',
'ratingValue',
'UserDownloads'
];
function convert(detailHtml) {
return new Promise(function (resolve, reject) {
var itemProps = {};
var elementItemProp;
var options = {};
var handler = new DomHandler(null, options);
new Parser(handler, options).end(detailHtml);
var dom = handler.dom;
function findDomElementsByTagName(dom, tag) {
return htmlparser.DomUtils.findAll(node => (node.type === 'tag' && node.name === tag), dom)
}