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

256
Visualizações
Dynamic Web scraping with PHP and Javascript

I'm trying to add a dynamic web scraping function to my website that gather data from another website automatically. Both websites have the same URL structure, and I use my website to generate the correct target url with a js script.

<script type="text/JavaScript">
  document.getElementById("demo").innerHTML = "https://www.website2.com" + window.location.pathname;
    </script>

Website 1. www.website1.com/test-123

Website 2. www.website2.com/test-123


I found the Simple HTML DOM Parser which allow me to go into a specific website and get HTLM elements.
However, it require a target URL. Is it possible to use the results from the script as a direct url?

Example: $html = file_get_html("#demo");?>

The code look like this:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>


    <?php include("simple_html_dom.php");
    $html = file_get_html("www.website2.com/test-123");?>


</head>
<body>
<h1>Företag</h1>
<?php echo $html->find("h1",0)->plaintext;?>

<h5><?php echo $html->find("h1",0)->plaintext;?></h5>

<?php
echo $html->find("h1",0)->plaintext;
echo $html->find("p",0)->plaintext;
echo $html->find("p",1)->plaintext;
echo $html->find("p",2)->plaintext;
?>


<?php
    echo "<div id='demo'></div>";
?>




</body>
<script type="text/JavaScript">
  
  document.getElementById("demo").innerHTML = "https://www.bolagsfakta.se" + window.location.pathname;
    </script>
</html>
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