Answer the question
In order to leave comments, you need to log in
Where is the mistake? Why doesn't the same script work after copying?
The same script, with minor changes. I’ve been comparing them line by line with a magnifying glass for half an hour and I just can’t understand why one works and the other doesn’t ?? Some kind of madness ...
Working script:
page.open(url, function(status) {
console.log('Status: ' + status);
// Do other things here...
var bestList = page.evaluate(function() {
var bestElements = document.querySelectorAll(
'#featured-books-inner .book-block-title'
);
var bestData = [];
for(var i = 0; i < bestElements.length; i++) {
bestData.push(bestElements[i].innerHTML.trim());
}
return bestData;
});
console.log('-----------------------------------');
for (var j = 0; j < bestList.length; j++) {
console.log((j + 1) + ' | ' + bestList[ j ]);
};
phantom.exit();
});
page.open(url, function(status) {
console.log('Status: ' + status);
// Do other things here...
var bestList = page.evaluate(function() {
var bestElements = document.querySelectorAll(
'#featured-books-inner .book-block-title'
);
var bestData = [];
for(var i = 0; i < bestElements.length; i++) {
bestData.push(bestElements[i].innerHTML.trim());
}
return bestData;
});
// log results
console.log('-----------------------------------');
for (var j = 0; j < bestList.length; j++) {
console.log((j + 1) + ' | ' + bestList[ j ]);
};
// exit
phantom.exit();
)}
Answer the question
In order to leave comments, you need to log in
No, well, it's full of tryndets. I found an error.")}" instead of "})"
And now the question is - HOW TO AVOID THIS?
Do you need to be covered with a bunch of tests in which to drown for several months just to quickly find bugs with brackets?
I'm shocked)))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question