Skip to content

Commit

Permalink
fix(scrap): don't fail page when error in user --field
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Dec 29, 2020
1 parent 36cca7d commit 74a6ecb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/scrap-site.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ module.exports = async (baseUrl, options = {}) => {
};

for (let name in customFields) {
result[name] = eval(customFields[name].replace(/`/g, '\''));
try {
result[name] = eval(customFields[name].replace(/`/g, '\''));
} catch(e) {
result[name] = `fiels ${name}: error parse ${customFields[name]}`;
}
// if(name == 'section') result[name] = $('.views-field.views-field-field-section a').text();
}

Expand Down Expand Up @@ -295,17 +299,17 @@ module.exports = async (baseUrl, options = {}) => {
}
});

/*page.on('error', function(err) {
/* page.on('error', function(err) {
console.error(`${color.red}Page error:${color.reset} ` + err.toString());
});*/
}); */

/*page.on('close', function() {
console.error(`${color.red}Page closed${color.reset} `);
});*/

/*page.on('pageerror', function(err) {
/* page.on('pageerror', function(err) {
console.error(`${color.red}pegeerror:${color.reset} ` + err.toString());
});*/
}); */

// console.log('co '+ crawler._options.url);

Expand Down

0 comments on commit 74a6ecb

Please sign in to comment.