3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php set_time_limit(0); date_default_timezone_set('Asia/Hong_Kong'); libxml_use_internal_errors(true); // $pathLeagueListCache = __DIR__. '/__league_list.txt'; $batchCount = 5; $xpathRegion = '//*[@id="btnGroup_EventSelection"]/ul'; $xpathRegionName = './/li[1]'; $xpathLeagueForRegionView = './/li[position()>1]'; $xpathLeagueIdForRegionView = './/input[@name="SportChk"]'; $xpathLeagueNameForRegionView = './/label'; $xpathLeague = '//div[@data-type="match"]'; $xpathLeagueName = './/h5'; $urlLeague = 'http://bb248.com/sb/Sport.aspx?s=137&lang=en'; $urlMatch = 'http://bb248.com/sb/event.aspx?lang=en'; $xpathMatch = './/div[@data-type="parent"]'; $xpathQueries = array( 'event_type' => './/span[@class="versus"]', 'event_name' => './/li[@data-symbol="eventname"]', 'home_name' => './/tr[@data-symbol="home"]/td[@data-symbol="name"]', 'away_name' => './/tr[@data-symbol="away"]/td[@data-symbol="name"]', 'home_match_odd' => './/tr[@data-symbol="home"]/td[@data-symbol="mb"]/button[@data-symbol="odd"]', 'away_match_odd' => './/tr[@data-symbol="away"]/td[@data-symbol="mb"]/button[@data-symbol="odd"]', 'hc_number' => './/tr[@data-symbol="home"]/td[@data-symbol="hc"]/p[@class="number-odds"]', 'home_hc_odd' => './/tr[@data-symbol="home"]/td[@data-symbol="hc"]/button[@data-symbol="odd"]', 'away_hc_odd' => './/tr[@data-symbol="away"]/td[@data-symbol="hc"]/button[@data-symbol="odd"]', 'total_number' => './/tr[@data-symbol="home"]/td[@data-symbol="ou"]/p[@class="number-overunder"]', 'home_total_odd' => './/tr[@data-symbol="home"]/td[@data-symbol="ou"]/button[@data-symbol="odd"]', 'away_total_odd' => './/tr[@data-symbol="away"]/td[@data-symbol="ou"]/button[@data-symbol="odd"]', 'datetime' => './/span[@data-symbol="datetime"]', ); function stripCountSuffix($name) { return preg_replace('/\\d+$/', '', $name); } $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_RETURNTRANSFER => true, )); curl_setopt($ch, CURLOPT_URL, $urlLeague); // //load league list $doc = new DOMDocument(); $doc->loadHTML(curl_exec($ch)); $regions = array(); $xpath = new DOMXpath($doc); var_dump($xpath); echo 'xx'; die(); var_dump($xpath->query($xpathRegion)); foreach($xpath->query($xpathRegion) as $region) { var_dump(get_class($region)); var_dump(get_class($xpath->query($xpathRegionName, $region)->item(0))); $regionName = stripCountSuffix($xpath->query($xpathRegionName, $region)->item(0)->nodeValue); echo $regionName; // foreach($xpath->query($xpathLeagueForRegionView, $region) as $league) { // $regions[$regionName][stripCountSuffix($xpath->query($xpathLeagueNameForRegionView, $region)[0]->nodeValue)] // = $xpath->query($xpathLeagueIdForRegionView, $league)[0]->getAttribute('value'); // } } // // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, $urlMatch); // $counter = 0; // $data = []; // while ($slice = array_slice(array_values(call_user_func_array('array_merge', $regions)), $counter * $batchCount, $batchCount)) { // $postData = [ // '__EVENTTARGET' => 'ctl00$ctl00$cphMainBody$cphMain75$imgEvSpHolder', // '__VIEWSTATEGENERATOR' => '9257D4C3', // 'SportChk' => $slice, // 'eventType' => 'handicap', // ]; // curl_setopt($ch, CURLOPT_POST, count($postData)); // //remove [index] suffix in post data field name which is causing problem // curl_setopt($ch, CURLOPT_POSTFIELDS, preg_replace('/%5B\d+%5D/simU', '', http_build_query($postData))); // $doc = new DOMDocument(); // $doc->loadHTML(curl_exec($ch)); // $xpath = new DOMXpath($doc); // foreach($xpath->query($xpathLeague) as $league) { // $leagueName = $xpath->query($xpathLeagueName, $league)[0]->nodeValue; // foreach($xpath->query($xpathMatch, $league) as $match) { // $datum = []; // $id = $match->getAttribute('data-symbol'); // $datum['league'] = $leagueName; // foreach($xpathQueries as $key => $query) { // $nodeList = $xpath->query($query, $match); // $datum[$key] = $nodeList->length > 0? trim($nodeList[0]->nodeValue): null; // } // $datum['has_hc'] = isset($datum['hc_number']); // $datum['has_match'] = isset($datum['home_match_odd']) && isset($datum['away_match_odd']); // $datum['has_total'] = isset($datum['total_number']); // $datum['total_number'] = isset($datum['total_number'])? ltrim($datum['total_number'], 'ou'):null; //total number // //if (array_key_exists('hc_number', $datum)) { // $datum['is_home_handicap'] = $datum['hc_number'] > 0; // $datum['hc_number'] = abs($datum['hc_number']); // //} // if ('at' == $datum['event_type']) { // foreach(['name', 'match_odd', 'hc_odd', 'total_odd'] as $key) { // list($datum['home_'. $key], $datum['away_'. $key]) = [$datum['away_'. $key], $datum['home_'. $key]]; // } // $datum['is_home_handicap'] = !$datum['is_home_handicap']; // } // // normalize odds // foreach($datum as $key => $value) { // if (stripos(strrev($key), strrev('_odd')) === 0 && !is_null($value)) { // $datum[$key] = $datum[$key] * 100 - 100; // } // } // $data[$id] = $datum; // $string = implode('|', [ // $id, // (new \DateTime($datum['datetime']))->format('Y-m-d H:i:s'), // $datum['event_name'], // $datum['home_name'], // null, // $datum['away_name'], // null, // (int)$datum['has_match'], //has match bet // null, //match id // isset($datum['home_match_odd'])? $datum['home_match_odd']: 0, // isset($datum['home_match_odd'])? 100: 1, // isset($datum['away_match_odd'])? $datum['away_match_odd']: 0, // isset($datum['away_match_odd'])? 100: 1, // (int)$datum['has_hc'], //has handicap bet // null, //handicap id // $datum['hc_number'], //handicap number // $datum['is_home_handicap'], //handicap number // isset($datum['home_hc_odd'])? $datum['home_hc_odd']: 0, // isset($datum['home_hc_odd'])? 100: 1, // isset($datum['away_hc_odd'])? $datum['away_hc_odd']: 0, // isset($datum['away_hc_odd'])? 100: 1, // (int)$datum['has_total'], //has handicap bet // null, //total id // $datum['total_number'], //total number // isset($datum['home_total_odd'])? $datum['home_total_odd']: 0, // isset($datum['home_total_odd'])? 100: 1, // isset($datum['away_total_odd'])? $datum['away_total_odd']: 0, // isset($datum['away_total_odd'])? 100: 1, // $datum['league'], // ]); // echo ($string); // echo '</br>'; // } // } // $counter++; // } // curl_close($ch); ?>
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/d8MoL:45 Stack trace: #0 {main} thrown in /in/d8MoL on line 45
Process exited with code 255.
Output for 5.3.20 - 5.6.28
Fatal error: Call to undefined function curl_init() in /in/d8MoL on line 45
Process exited with code 255.