Archived
1
0
Fork 0
This repository has been archived on 2020-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
news-script/Source/Kvester.php
Alexander Yakovlev 63a13577f9 Улучшенный парсер Квестера
Добавил загрузку описаний игр с Квестера
2017-08-18 21:35:26 +07:00

32 lines
1.1 KiB
PHP

<?php
namespace Source;
use \Game;
class Kvester extends Source {
public $title = "Квестер";
protected function parse() {
$text = $this->get_text("http://kvester.ru/catalog?sort=date");
$this->dom->loadStr($text, []);
unset($text);
$games = $this->dom->find('.catalog-item');
foreach ($games as $gameBlock) {
$date = trim($gameBlock->find('.cell-2 .date')->innerHtml, "() \t\n\r\0\x0B");
$date = \DateTime::createFromFormat("d.m.y", $date);
if ($date === false) continue;
$date = $date->format('U');
if ($date < $this->period) continue;
$game = new Game;
$game->author = trim(strip_tags($gameBlock->find('.cell-2 .author')->innerHtml));
$game->title = trim($gameBlock->find('.cell-2 h3 a')->text);
$game->url = 'http://kvester.ru'.trim($gameBlock->find('.cell-2 h3 a')->getAttribute('href'));
$game->description = "";
$this->dom->loadStr($this->get_text($game->url), []);
$game->description = $this->dom->find('.description')->innerHtml;
$this->output .= $game->print();
}
}
}