Пример #1
0
 public function actionFillcountries()
 {
     $countries = Country::find()->all();
     foreach ($countries as $country) {
         try {
             if (TeamSum::find()->where("name like '" . addslashes($country->name) . "'")->one()) {
                 continue;
             } else {
                 $team = new TeamSum();
                 $team->name = $country->name;
                 $team->tournament_id = 4;
                 $team->is_club = 0;
                 $team->save(false);
                 //var_dump($team);
             }
         } catch (\ErrorException $e) {
             echo $e->getMessage();
         }
         //  if($country->id == 11) { $country->iso_code = 'ad'; $country->soccer_code = 19; $country->update(); }
     }
 }
Пример #2
0
 /**
  * Коэффициенты УЕФА
  */
 public function actionParsRatingUefaTeams()
 {
     $url = "http://www.profootball.ua/ranking/uefa_teams.html";
     $content = $this->cut_content($this->get_page($url), 'class="t1"', 'UEFA Ranking By Bert Kassies');
     $dom = new \DomDocument();
     libxml_use_internal_errors(true);
     $head = file_get_contents(Url::to("@app/commands/header.html"));
     $teams = $head . $content;
     //добавляем хэдер
     $dom->loadHTML($teams);
     $tr = $dom->getElementsByTagName("tr");
     foreach ($tr as $node) {
         $dom_in = new \DomDocument();
         $html = $node->ownerDocument->saveHTML($node);
         libxml_use_internal_errors(true);
         $newhtml = $head . $html;
         $dom_in->loadHTML($newhtml);
         $td = $dom_in->getElementsByTagName("td");
         foreach ($td as $node) {
             echo $node->nodeValue . PHP_EOL;
             if ($td[2]->nodeValue == 'Rus') {
                 break;
             }
             $team = new TeamSum();
             $team->tournament_id = 2;
             $team->alias = $td[1]->nodeValue;
             $team->country = $td[2]->nodeValue;
             $team->rank1old = $td[3]->nodeValue;
             $team->rank2old = $td[4]->nodeValue;
             $team->rank3old = $td[5]->nodeValue;
             $team->rank4old = $td[6]->nodeValue;
             $team->rank5old = $td[7]->nodeValue;
             $team->rank = $td[8]->nodeValue;
             $team->save(false);
             break;
         }
         echo "--------------------" . PHP_EOL;
     }
 }