Такая проблема, копирую список стримов с сайта через SimpleHTMLDOM. Проблема в том, что список размещен на нескольких страницах-категориях. Через foreach я делаю загрузку нескольких категорий, однако начиная со второй итерации функции simple HTML DOM не работают.
<?php
include "simple_html_dom.php";
function GetRWGames($rw_cat){
$live = new simple_html_dom();
$live->load_file("http://live.robinwidget.org/static/section" . $rw_cat . ".html");
$data = $live->find(".lshpanel");
$counter = 0;
foreach($data as $game) {
$games[$counter][cat] = $game->find(".section",0)->plaintext;
$games[$counter][time] = $game->find(".date",0)->plaintext;
$temp = $game->find(".lshevent",0)->plaintext;
$temp = explode(" - ", $temp);
$games[$counter][team1] = trim ($temp[0]);
$games[$counter][team2] = trim ($temp[1]);
$temp = $game->find("a");
foreach ($temp as $a) {
$a=$a->href;
if(stristr($a, "javascript:openWindow")==true){
$temp= strstr($a, "http");
$temp= strstr($temp, '"',1);
$games[$counter][links] .= $temp . ";";}
elseif(!strpos($a,"adserving")&&!strpos($a,"adsrv")&&!empty($a))
{$games[$counter][links] .= $a . ";";}
}
$counter++;
}
return $games;
}
$games = array();
// Load HTML from a string
$rw_cats = array(35,36,37,38,39,57,59);
foreach($rw_cats as $rw_cat){
print_r(GetRWGames($rw_cat));
}
Ошибка:
Fatal error: Uncaught Error: Call to a member function find() on null in D:\os\OpenServer\domains\newtest.ru\simple_html_dom.php:1113 Stack trace: #0 D:\os\OpenServer\domains\newtest.ru\index.php(7): simple_html_dom->find('.lshpanel') #1 D:\os\OpenServer\domains\newtest.ru\index.php(34): GetRWGames(36) #2 {main} thrown in D:\os\OpenServer\domains\newtest.ru\simple_html_dom.php on line 1113
Первая итерация проходит успешно, я получаю данные. Во второй итерации find перестает работать. При этом страницы вроде как загружаются, проверял просто загрузкой и выводом. Пробовал генерировать имя $live, вручную предоставлять объект simple_html_dom для обработки в $data, делал вовсе без циклов, вручную перебирая итерации. Постоянно ошибка на первом find.