I'm trying to extract some <div> elements from this html:
<html>
<head> ... </head>
<body>
<div>
<div class="app-wrapper">
<header class="position-sticky top-0 left-0 w-100 z-index-111 mb-20px"> ... </header>
<div class="app-content">
<div class="container">
<div class="rounded mb-10px bg-white">
<div class="d-flex flex-column flex-m-row p-m-14px">
... some html ...
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Using this PhantomJS code:
var webPage = require('webpage');
var page = webPage.create();
var link = " "
page.open(link, function (status) {
var elems = page.evaluate(function () {
return [].map.call(document.getElementsByClassName('d-flex flex-column flex-m-row p-m-14px'), function (elem) {
return elem.innerHTML
});
});
console.log(elems); //logs []
phantom.exit();
})
I thought it logs nothing due to the styling used in the class, but using this function for app-wrapper and app-content classes gave no result as well. It worked only with the container class and returned an array with a single element. Why doesn't it work for two other classes?