DOM PHP-致命错误:未捕获错误:在null上调用成员函数find()

时间:2019-03-11 23:00:17

标签: php dom simple-html-dom

我有此代码,并且收到此错误

  

致命错误:未捕获错误:在/storage/public_html/index.php:94中对null的成员函数find()进行调用:堆栈跟踪:#0 {main}在/storage/public_html/index.php中抛出94

        require 'simple_html_dom.php';
        $html = file_get_html('https://linkotes.com/arenavision/');
        $html2 = file_get_html('https://acelisting.in');

        $linkotes = $html->find('div[id=agenda_av] ',0);

          echo '<div class="container" align="center">';
            $i = 0;
            $j = 0;
            $k = 2;
            while ($i <200 && $k < 200) {
              $hora = $linkotes -> find('td',$i+4)." - "; //hora linkotes
              $partido = $linkotes -> find('td',$k);//partido linkotes


              $tabla_equipos = $html2->find('div[class=container-fluid id=contentContainer], div[row] div[class=col-sm-8], td',$i+4);
              $hora = $html2->find('div[class=container-fluid id=contentContainer], div[row] div[class=col-sm-8], td',$i+1);
              $dia = $html2->find('div[class=container-fluid id=contentContainer], div[row] div[class=col-sm-8], td',$i+2);
              $enlaces = $html2->find('div[class=container-fluid id=contentContainer], div[row] div[class=col-sm-8], td',$i+7);

     /*the next if is line 94*/
            if (is_null($tabla_equipos->find('td',0)) ){
                $i = 200;
                $k = 200;

            }
            else{
                $equipos = $tabla_equipos->find('td',0); //Equipos;
              $competicion = $tabla_equipos->find('td',1); //$competicion
              $data = str_replace("-", " vs ", $equipos);

              if (preg_match('/ATLETICO MADRID/',$equipos)){
                echo $dia.' - '.$hora.' / ';
                echo $data;
                $link_auto = $enlaces -> find('a[href]', 0);
                $enlace_auto = $link_auto->getAttribute('href'); //Enlace acestream
                echo '<br><br><a class="btn btn-success" href="'.$enlace_auto.'"role="button">VER PARTIDO</a><br><br>';
              }else if (preg_match('/REAL MADRID/',$equipos)) {
                echo $dia.' - '.$hora.' / ';
                echo $data;
                $link_auto = $enlaces -> find('a[href]', 0);
                $enlace_auto = $link_auto->getAttribute('href'); //Enlace acestream
                echo '<br><br><a class="btn btn-success" href="'.$enlace_auto.'"role="button">VER PARTIDO</a><br><br>';
              }else if (preg_match('/SPANISH LA LIGA/',$competicion)) {
                echo $dia.' - '.$hora.' / ';
                echo $data;
                $link_auto = $enlaces -> find('a[href]', 0);
                $enlace_auto = $link_auto->getAttribute('href'); //Enlace acestream
                echo '<br><br><a class="btn btn-success" href="'.$enlace_auto.'"role="button">VER PARTIDO</a><br><br>';
              }
              $i= $i+ 8;
              $k = $k+4;
            }
}

如果$ tabla_equipos-> find('td',0)为null stop,我不知道该怎么设置

0 个答案:

没有答案