Добрый день, друзья! Подскажите, почему перестал работать парсер. Раньше все работало, а сейчас что-то случилось =((
Вот код:
$html = file_get_contents('http://www.gosugamers.net/hearthstone/gosubet');
$matchList = new simple_html_dom();
$matchList->load($html);
$titleList = new simple_html_dom();
$gameArray = array();
$output = array();
$done = $matchList->find('.matches', 2);
if ($done) { $d0 = 0;
$d1 = 1;
$d2 = 2;
$live = true;
} else {
$d0 = 0;
$d1 = 0;
$d2 = 1;
$live = false;
}
$upcoming = $matchList->find('#col1 > .box', 1);
$game = null;
foreach($upcoming->find('tr') as $aGame) {
$img1 = "http://www.gosugamers.net".$aGame->find('img', 0)->src;
$img2 = "http://www.gosugamers.net".$aGame->find('img', 1)->src;
$linkID = "http://www.gosugamers.net".$aGame->find('a', 0)->href;
$date = trim($aGame->find('.live-in', 0)->plaintext);
$html = file_get_contents($linkID);
$titleList->load($html);
$team1 = $titleList->find('h3', 0)->plaintext;
if (!$team1) {
continue;
}
$team2 = $titleList->find('h3', 1)->plaintext;
$bestof = $titleList->find('.match-extras .bestof', 0)->plaintext;
$bestof = current(array_slice(explode(' ', $bestof), 2, 1));
if(!is_numeric($bestof)) $bestof = '?';
$eventName = $titleList->find('.box-match-page > h2 a', 0)->plaintext . " [BO{$bestof}]";
$fullDate = $titleList->find('.match-extras .datetime', 0)->plaintext;
$fullDate = str_replace("at", "", $fullDate);
$fullDate = $fullDate . " CET";
$timeStamp = strtotime($fullDate);
$game['img1'] = $img1;
$game['team1'] = $team1;
$game['img2'] = $img2;
$game['team2'] = $team2;
$game['eventName'] = $eventName;
$game['fullDate'] = $fullDate;
$game['liveIn'] = $date;
$output["upcoming"][] = $game;
} //done
$str = json_encode($output);
$filestr = "hearthstone_upcoming.json";
$fp=@fopen($filestr, 'w');
fwrite($fp, $str);
fwrite($fp, "");
fclose($fp);
echo $str;