Archived
1
0
Fork 0

Новости инстеда

This commit is contained in:
Alexander Yakovlev 2018-03-25 02:42:13 +07:00
parent dab34de99b
commit ce8a0386b9

View file

@ -7,20 +7,19 @@ class Instead extends Source {
public $title = "INSTEAD репозиторий"; public $title = "INSTEAD репозиторий";
protected function insteadfeed($url) { protected function insteadfeed($url) {
$text = $this->get_text($url); $text = $this->get_text($url);
$this->dom->loadStr($text, []); $this->loadStr($text);
unset($text); unset($text);
$games = $this->dom->find('.game'); $this->dom->filter('.game')->each(function($gameBlock) {
foreach ($games as $gameBlock) { $date = trim($gameBlock->filter('.b .date b')->text());
$date = trim($gameBlock->find('.b .date b')->innerHtml);
$date = \DateTime::createFromFormat('Y.m.d', $date); $date = \DateTime::createFromFormat('Y.m.d', $date);
$date = $date->format('U'); $date = $date->format('U');
if ($date < $this->period) continue; if ($date < $this->period) return;
$game = new Game; $game = new Game;
$game->author = str_replace(trim($gameBlock->find('span.author')->innerHtml), 'Автор: ', ''); $game->author = str_replace(trim($gameBlock->filter('span.author')->first()->text()), 'Автор: ', '');
$game->title = trim($gameBlock->find('h2')[0]->find('a')[0]->innerHtml); $game->title = trim($gameBlock->filter('h2:first-child a:first-child')->first()->text());
$game->url = 'http://instead-games.ru/'.trim($gameBlock->find('h2')[0]->find('a')[0]->getAttribute('href')); $game->url = 'http://instead-games.ru/'.trim($gameBlock->filter('h2:first-child a:first-child')->first()->attr('href'));
$this->output .= $game->print(); $this->output .= $game->print();
} });
} }
protected function parse() { protected function parse() {
$this->insteadfeed("http://instead-games.ru/"); $this->insteadfeed("http://instead-games.ru/");