} // Получаем перечень ставок $PostData = array(); $PostData['leagueIDs'] = $LeagueList; $PostData['sorting'] = "dateleague"; $PostData['categoryIDs'] = $CategoryId; $PostData['currentPage'] = $CurrentPage; if ($debug) { $FileName = $Lines . "{$CurrentPage}.bets.html"; if (!file_exists($FileName)) { $Html = download("https://www.bwin.com/betviewiframe.aspx", "GET", "https://www.bwin.com/{$Sport}?ShowDays=168", $PostData); file_put_contents($FileName, $Html); } else { $Html = file_get_contents($FileName); } } else { $Html = download("https://www.bwin.com/betviewiframe.aspx", "GET", "https://www.bwin.com/{$Sport}?ShowDays=168", $PostData); } $Result = extract_bet(utf8_to_ansi_ru(utf8_to_ansi_ce($Html))); if (stripos($Html, '"pagingGotoNextItem"') == 0) { $Result .= '"LastPage=True"'; } else { $Result .= '"LastPage=False"'; } if ($debug) { file_put_contents($Lines . 'bets.txt.html', $Result); } print $Result; ?>
function extract_bets_foratotal(&$tournir_node, $html, $sport_sign, $tournir_id, $category_id) { $i = 0; $filename_headers = "phrases/bwin/{$sport_sign}.headers.txt"; $filename_labels = "phrases/bwin/{$sport_sign}.labels.txt"; $phrases_headers = file_get_hash($filename_headers); $phrases_labels = file_get_hash($filename_labels); $html = kill_space($html); $html = numbering_tag($html, 'tr'); $table_rows = extract_all_numbered_tags($html, 'tr', 'class'); // file_put_contents("lines/bwin/$tournir_id.Total.html", $html); foreach ($table_rows as $row) { $row = kill_property($row, 'TagNo'); $header = copy_be($row, '<tr', '>'); $row_class_name = extract_property_values($header, 'class', null); if ($row_class_name == 'topbar') { // разбираем дату $row = copy_between($row, '<h3>', '</h3>'); list($day_no, $month_no, $year_no) = decode_date($row); } elseif (in_array($row_class_name, array('def', 'alt'))) { // игроки + время if (preg_match('/<td.*>(<h4>)*?(.+) - (.+) - (\\d{1,2}:\\d\\d (PM|AM))(.*?)(<\\/h4>)*?</Ui', $row, $matches)) { $gamer1_name = utf8_to_ansi_ce($matches[2]); $gamer2_name = utf8_to_ansi_ce($matches[3]); list($hour, $minute) = decode_time($matches[4]); } elseif (preg_match('/<td.*>(<h5>)*?(.+)(<\\/h5>)*?</iU', $row, $matches)) { $phrase = utf8_to_ansi_ce($matches[2]); unset($bettype); $phrase = str_ireplace($gamer1_name, 'Gamer1', $phrase); $phrase = str_ireplace($gamer2_name, 'Gamer2', $phrase); $bettype_str = $phrases_headers[$phrase]; if ($bettype_str) { foreach (explode(';', $bettype_str) as $bet_pair) { list($key, $value) = explode('=', $bet_pair); $bettype[$key] = $value; } } else { $bettype['Modifier'] = 'Unknown'; $phrases_headers[$phrase] = 'Modifier=Unknown'; $phrases_headers_modified = true; } } } elseif ($row_class_name == 'normal' and $bettype) { // основная ставка if (!in_array($bettype['Modifier'], array('Ignore', 'Unknown'))) { $tables = extract_all_tags($row, '<table', '</table>'); foreach ($tables as $table) { list($label, $koef) = extract_label_koef($table); $label = str_ireplace($gamer1_name, 'Gamer1', $label); $label = str_ireplace($gamer2_name, 'Gamer2', $label); // подбираем формат фразы метки $modifier = $phrases_labels[$label]; if ($modifier) { foreach (explode(';', $modifier) as $bet_pair) { list($key, $value) = explode('=', $bet_pair); $bettype[$key] = $value; } } else { $bettype['Modifier'] = 'Unknown'; $phrases_labels[$label] = 'Modifier=Unknown'; $phrases_labels_modified = true; } if (!in_array($bettype['Modifier'], array('Ignore', 'Unknown'))) { $event_node = event_find_or_create($tournir_node, mktime($hour, $minute, 0, $month_no, $day_no, $year_no), $gamer1_name, $gamer2_name); $bet_node = $event_node->addChild('Bet'); foreach ($bettype as $key => $value) { $bet_node->addAttribute($key, $value); } $bet_node->addAttribute('Koef', $koef); } unset($bettype['Modifier']); } } } $i++; } // отбираем новые и складываем их в новый файл if ($phrases_headers_modified) { $file_hash = file_get_hash($filename_headers); foreach ($file_hash as $key => $value) { unset($phrases_headers[$key]); } file_put_hash($filename_headers . '.new', $phrases_headers + file_get_hash($filename_headers . '.new')); } if ($phrases_labels_modified) { $file_hash = file_get_hash($filename_labels); foreach ($file_hash as $key => $value) { unset($phrases_labels[$key]); } file_put_hash($filename_labels . '.new', $phrases_labels + file_get_hash($filename_labels . '.new')); } }