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

255
Views
Web scraping dinámico con PHP y Javascript

Estoy tratando de agregar una función de raspado web dinámico a mi sitio web que recopila datos de otro sitio web automáticamente. Ambos sitios web tienen la misma estructura de URL y utilizo mi sitio web para generar la URL de destino correcta con un script js.

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

Sitio web 1. www.website1.com/test-123

Sitio web 2. www.website2.com/test-123


Encontré el Simple HTML DOM Parser que me permite ingresar a un sitio web específico y obtener elementos HTLM.
Sin embargo, requiere una URL de destino. ¿Es posible usar los resultados del script como una URL directa?

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

El código se ve así:

 <!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
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!