From ce8a0386b95aa84a16a481444727fddc186a5292 Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Sun, 25 Mar 2018 02:42:13 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D0=BE=D1=81=D1=82=D0=B8=20?= =?UTF-8?q?=D0=B8=D0=BD=D1=81=D1=82=D0=B5=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/Instead.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Source/Instead.php b/Source/Instead.php index 877b2e8..7da3c4d 100644 --- a/Source/Instead.php +++ b/Source/Instead.php @@ -7,20 +7,19 @@ class Instead extends Source { public $title = "INSTEAD репозиторий"; protected function insteadfeed($url) { $text = $this->get_text($url); - $this->dom->loadStr($text, []); + $this->loadStr($text); unset($text); - $games = $this->dom->find('.game'); - foreach ($games as $gameBlock) { - $date = trim($gameBlock->find('.b .date b')->innerHtml); + $this->dom->filter('.game')->each(function($gameBlock) { + $date = trim($gameBlock->filter('.b .date b')->text()); $date = \DateTime::createFromFormat('Y.m.d', $date); $date = $date->format('U'); - if ($date < $this->period) continue; + if ($date < $this->period) return; $game = new Game; - $game->author = str_replace(trim($gameBlock->find('span.author')->innerHtml), 'Автор: ', ''); - $game->title = trim($gameBlock->find('h2')[0]->find('a')[0]->innerHtml); - $game->url = 'http://instead-games.ru/'.trim($gameBlock->find('h2')[0]->find('a')[0]->getAttribute('href')); + $game->author = str_replace(trim($gameBlock->filter('span.author')->first()->text()), 'Автор: ', ''); + $game->title = trim($gameBlock->filter('h2:first-child a:first-child')->first()->text()); + $game->url = 'http://instead-games.ru/'.trim($gameBlock->filter('h2:first-child a:first-child')->first()->attr('href')); $this->output .= $game->print(); - } + }); } protected function parse() { $this->insteadfeed("http://instead-games.ru/");