Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
How to extract elements from html source with phantomjs?

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?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!