//zatim vse: 151526 //read the saved tables scraperwiki::attach("eurofotbalcz_1", "src"); $rows = scraperwiki::select("* from src.swdata where id>{$last_id} and country='de' order by id"); //germany only //$rows = scraperwiki::select("* from src.swdata where id>{$last_id} order by id"); foreach ($rows as $row) { $url = 'http://www.eurofotbal.cz' . $row['link']; $html = scraperwiki::scrape($url); //get dom $dom = new simple_html_dom(); $dom->load($html); //info $match_id = $row['id']; $date_ar = explode(' ', $dom->find('div[class=date]', 0)->innertext); $date = date2iso($date_ar[0]); $time = $date_ar[1] != '?' ? $date_ar[1] : ''; $part = is_object($dom->find('div[class=stage]', 0)) ? $dom->find('div[class=stage]', 0)->plaintext : ''; //teams $table = $dom->find('table', 0); $h2 = $table->find('h2', 0); $home_link = $h2->find('a', 0)->href; $visitor_link = $h2->find('a', 1)->href; $home = $h2->find('a', 0)->plaintext; $visitor = $h2->find('a', 1)->plaintext; $result_ar0 = explode('<', $table->find('tr', 1)->find('td', 1)->innertext); $result = trim(str_replace(' ', '', $result_ar0[0]), ','); $result_ar = explode(':', $result); //sub results $result1 = $table->find('tr', 1)->find('td', 1)->find('span'); if (count($result1) > 1) {
$dom = new simple_html_dom(); $dom->load($html); //extract data $h2s = $dom->find('h2[class=pagesubtitle]'); $tables = $dom->find('table[class=matches]'); //get rid of "posledni zapasy" array_pop($tables); //get rid of "Nasledujici zapasy" if (count($tables) > 1) { array_pop($tables); } $data = array(); foreach ($tables as $mkey => $table) { $trs = $table->find('tr'); foreach ($trs as $tr) { $date = date2iso($tr->find('td', 0)->plaintext); $time = $tr->find('td[class=time]', 0)->plaintext; $teams = explode(' - ', $tr->find('td[class=teams]', 0)->find('div[class=fl]', 0)->innertext); //echo '**'; $result = $tr->find('td', 3)->plaintext; //echo $result; $link = $tr->find('td', 3)->find('a', 0)->href; if ($result != 'info') { //it has been played already $result_ar = explode(':', $result); $id = trim(end(explode('-', $link)), '/'); $data[] = array('id' => $id, 'country' => $key, 'league' => $league['name'], 'season' => $season, 'part' => isset($h2s[$mkey]) ? $h2s[$mkey]->plaintext : '', 'date' => $date, 'time' => $time == '?' ? '' : $time, 'home' => trim($teams[0]), 'visitor' => trim($teams[1]), 'result' => $result, 'home_goals' => $result_ar[0], 'visitor_goals' => $result_ar[1], 'result_code' => result_code($result_ar), 'link' => $link); //echo $teams[0].$tr->find('td[class=date]',0)->plaintext; } } }