123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- /*
- Microblog bot for game release notifications
- Copyright (C) 2017 Alexander Yakovlev
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- namespace Source;
- use \Game;
- class Apero extends Source {
- public $title = "Apero";
- protected function parse() {
- $formatter = new \IntlDateFormatter( 'ru', \IntlDateFormatter::LONG, \IntlDateFormatter::NONE );
- $text = $this->get_text('http://apero.ru/');
- $this->dom->loadStr($text, []);
- unset($text);
- $games = $this->dom->find('.tabled-game-block');
- foreach ($games as $gameBlock) {
- $date = trim($gameBlock->find('.game-updated-block')->innerHtml, "() \t\n\r\0\x0B");
- $date = $formatter->parse($date);
- if ($date < $this->period) continue;
- $game = new Game;
- $game->author = trim($gameBlock->find('.game-author-block')[0]->find('a')->innerHtml);
- $game->title = trim($gameBlock->find('h2')[0]->find('a')[0]->innerHtml);
- $game->url = trim($gameBlock->find('h2')[0]->find('a')[0]->getAttribute('href'));
- $game->description = trim($gameBlock->find('.game-desc-block')[0]->innerHtml);
- $this->games[] = $game;
- }
- }
- }
|