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

47 lines
1.7 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->loadStr($text);
unset($text);
$this->dom->filter('.catalog-item')->each(function($gameBlock){
$date = trim($gameBlock->filter('.cell-2 .date')->text(), "() \t\n\r\0\x0B");
$date = \DateTime::createFromFormat("d.m.y", $date);
if ($date === false) return;
$date = $date->format('U');
if ($date < $this->period) return;
$game = new Game;
$game->author = trim(strip_tags($gameBlock->filter('.cell-2 .author')->text()));
$game->title = trim($gameBlock->filter('.cell-2 h3 a')->text());
$game->url = 'http://kvester.ru'.trim($gameBlock->filter('.cell-2 h3 a')->attr('href'));
$game->description = "";
$this->loadStr($this->get_text($game->url), []);
$game->description = $this->dom->filter('.description')->first()->text();
$this->output .= $game->print();
});
}
public function checkPage($url) {
return (strpos($url,'http://kvester.ru/game/') !== FALSE);
}
public function page($url) {
$game = new Game;
$game->url = $url;
$game->platform = 'Квестер';
$game->title = trim($this->dom->filter(".qt-in-1 h2")->first()->text());
$game->author = trim($this->dom->filter('.quest-info .author a')->text());
$game->date = \DateTime::createFromFormat(
'd.m.y',
trim($this->dom->filter('.quest-info .date')->first()->text())
);
$game->description = trim($this->dom->filter('.quest-profile .description')->first()->text());
return $game;
}
}