How do I get the HTML array back in .then(function(document){})
,
all code:
const phantom = require('phantom');
(async function() {
const instance = await phantom.create();
const page = await instance.createPage();
const status = await page.open('https://lasgsfgdf.com/').then(function (status) {
if(status == 'success') {
page.evaluate(function() {
return document.querySelectorAll('.resourceList > .resourceListItem');
}).then(function(document){
console.log(document[0].innerHTML);
});
}
});
await page.close();
await instance.exit();
})();
Works only when the string is returned.
page.evaluate(function() {
return document.querySelectorAll('.resourceList > .resourceListItem')[0].innerHTML;
}).then(function(document){
console.log(document);
});
I need so that I can process the array, already in then
, since in .evaluate(function() {
работает только return
, no idea why so.