Ver Mensaje Individual
  #5 (permalink)  
Antiguo 17/09/2016, 06:08
xoceunder
 
Fecha de Ingreso: junio-2012
Ubicación: En el Mundo
Mensajes: 759
Antigüedad: 11 años, 10 meses
Puntos: 10
Respuesta: duda en obtener datos de web con php

Estoy usando esto

Código PHP:
Ver original
  1. <?php
  2. include('simple_html_dom.php');
  3.  
  4. date_default_timezone_set('America/New_York');
  5.  
  6. $link = 'http://www.ontvtonight.com/guide/listings/channel/69022174/wcbs-hdtv.html';
  7.  
  8.  
  9. $html = file_get_html($link);
  10. $date = array();
  11. $titulo = array();
  12. $tabla = array();
  13. foreach($html->find('tbody tr') as $key=>$value) {
  14.     foreach($html->find('tbody tr td h5.thin') as $row) {
  15.         if(!$row->find('a')) {
  16.      $date[] = preg_replace("/[\r\n\t]+/", "",$row->plaintext);
  17.         }
  18.     }
  19.     foreach($html->find('tbody tr td h5.thin a') as $row) {
  20.      $titulo[] = preg_replace("/[\r\n\t]+/", "", $row->plaintext);
  21.     }
  22.     $tabla[$date[$key]] = $titulo[$key];
  23. }
  24.  
  25. $array = $tabla;
  26.  
  27. $copiar = 0;
  28. $fecha_actual = date("h:i a");
  29. $array_final = [];
  30.  
  31. foreach($array as $date => $value){
  32.   if($date >= $fecha_actual)  $copiar = 1;
  33.   if($copiar == 1)            $array_final[$date] = $value;
  34. }
  35.  
  36. echo "<pre>",print_r($array_final),"</pre>";  
  37. ?>

pero no me quiere funcionar

Última edición por xoceunder; 17/09/2016 a las 06:37