Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

153
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda