$xml = new SimpleXMLElement("<Scan/>"); $xml->addAttribute('id', $ScanId); function extract_league($Html) { global $xml; $Html = extract_tags($Html, '<a href=\'betsnew.aspx?leagueids=', '>', "\r\n"); preg_match_all('/(\\d+)/m', $Html, $Matches); foreach ($Matches[1] as $league_id) { $xml->addChild('Tournir', $league_id); } } // Получаем перечень турниров if ($debug) { $FileName = $Leagues . "league.html"; if (!file_exists($FileName)) { $Html = download_curl("{$Host}/{$Sport}?ShowDays=168", "GET", $Proxy); file_put_contents($FileName, $Html); } else { $Html = file_get_contents($FileName); } } else { $Html = download("{$Host}/{$Sport}?ShowDays=168", "GET", $Proxy); } extract_league($Html, $xml); if ($debug) { file_put_contents($Leagues . "league.xml", $xml->asXML()); } foreach ($xml->Scan->League as $league) { } file_put_contents($Leagues . "league.xml", $xml->asXML()); print $xml->asXML();
function download_or_load($debug, $file_name, $url, $method, $referer = null, $post_hash = null) { if (file_exists('proxy.txt')) { $proxy = file_get_contents('proxy.txt'); } make_path($file_name, true); if ($debug) { if (!file_exists($file_name)) { if ($proxy) { $html = download_curl($url, $method, $proxy, $referer, $post_hash); } else { $html = download($url, $method, $referer, $post_hash); } file_put_contents($file_name, $html); } else { $html = file_get_contents($file_name); } } else { if ($proxy) { $html = download_curl($url, $method, $proxy, $referer, $post_hash); } else { $html = download($url, $method, $referer, $post_hash); } } return $html; }
} } } } function extract_league($Html) { $Html = extract_tags($Html, '<a href="betsnew.aspx?leagueids=', '>', "\r\n"); preg_match_all('/(\\d+)/m', $Html, $Matches); $Html = implode(",", $Matches[1]); return $Html; } // Получаем перечень турниров if ($debug) { $FileName = $Leagues . "league.html"; if (!file_exists($FileName)) { $Html = download_curl("https://www.bwin.com/{$Sport}?ShowDays=168", "GET", $Proxy); file_put_contents($FileName, $Html); } else { $Html = file_get_contents($FileName); } } else { $Html = download("https://www.bwin.com/{$Sport}?ShowDays=168", "GET", $Proxy); } $LeagueList = extract_league(utf8_to_ansi_ru(utf8_to_ansi_ce($Html))); if ($debug) { file_put_contents($Leagues . "league.txt", $LeagueList); } function extract_bet($Html) { $Html = delete_all($Html, "(at ", ")"); $Html = delete_all($Html, "(score: ", ")");