From 291250c6a04c0ee1abfca3f19a0ff127b898ee4d Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Wed, 11 Apr 2018 20:54:37 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B4=D0=BB=D1=8F=20=D0=9A=D0=B2=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Game.php | 1 + Source/Kvester.php | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Game.php b/Game.php index 72b385c..826156e 100644 --- a/Game.php +++ b/Game.php @@ -18,6 +18,7 @@ class Game { public $url_download; public $url_discussion; public $url_download_description; + public $url_online_description; public $language; public $categories; public function print() { diff --git a/Source/Kvester.php b/Source/Kvester.php index c51ed14..ed51271 100644 --- a/Source/Kvester.php +++ b/Source/Kvester.php @@ -5,8 +5,9 @@ use \Game; class Kvester extends Source { public $title = "Квестер"; + protected $baseUrl = 'http://kvester.ru'; protected function parse() { - $text = $this->get_text("http://kvester.ru/catalog?sort=date"); + $text = $this->get_text($this->baseUrl."/catalog?sort=date"); $this->loadStr($text); unset($text); $this->dom->filter('.catalog-item')->each(function($gameBlock){ @@ -18,21 +19,22 @@ class Kvester extends Source { $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->url = $this->baseUrl.trim($gameBlock->filter('.cell-2 h3 a')->attr('href')); $game->description = ""; - $this->loadStr($this->get_text($game->url), []); + $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); + return (strpos($url, $this->baseUrl.'/game/') !== FALSE); } public function page($url) { $game = new Game; $game->url = $url; + $game_id = (int) str_replace($this->baseUrl.'/game/', '', $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()); @@ -40,7 +42,17 @@ class Kvester extends Source { 'd.m.y', trim($this->dom->filter('.quest-info .date')->first()->text()) ); + $game->url_online = $this->baseUrl.trim($this->dom->filter(".play a")->first()->attr('href')); + $game->url_online_description = 'Играть онлайн на Квестер.ру'; $game->description = trim($this->dom->filter('.quest-profile .description')->first()->text()); + $game->image = $this->baseUrl.trim($this->dom->filter('.quest-profile .cell-1 img')->first()->attr('src')); + if ($game->author === 'Совместный') { + $this->loadStr($this->get_text($this->baseUrl.'/game/quest/team/'.$game_id.'?ts_mode=public')); + $game->author = []; + $this->dom->filter('.team-item a .txt')->each(function($author) use($game){ + $game->author[] = $author->text(); + }); + } return $game; } }