Улучшения для Квестера
This commit is contained in:
parent
3aea8f89f3
commit
291250c6a0
1
Game.php
1
Game.php
|
@ -18,6 +18,7 @@ class Game {
|
||||||
public $url_download;
|
public $url_download;
|
||||||
public $url_discussion;
|
public $url_discussion;
|
||||||
public $url_download_description;
|
public $url_download_description;
|
||||||
|
public $url_online_description;
|
||||||
public $language;
|
public $language;
|
||||||
public $categories;
|
public $categories;
|
||||||
public function print() {
|
public function print() {
|
||||||
|
|
|
@ -5,8 +5,9 @@ use \Game;
|
||||||
|
|
||||||
class Kvester extends Source {
|
class Kvester extends Source {
|
||||||
public $title = "Квестер";
|
public $title = "Квестер";
|
||||||
|
protected $baseUrl = 'http://kvester.ru';
|
||||||
protected function parse() {
|
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);
|
$this->loadStr($text);
|
||||||
unset($text);
|
unset($text);
|
||||||
$this->dom->filter('.catalog-item')->each(function($gameBlock){
|
$this->dom->filter('.catalog-item')->each(function($gameBlock){
|
||||||
|
@ -18,21 +19,22 @@ class Kvester extends Source {
|
||||||
$game = new Game;
|
$game = new Game;
|
||||||
$game->author = trim(strip_tags($gameBlock->filter('.cell-2 .author')->text()));
|
$game->author = trim(strip_tags($gameBlock->filter('.cell-2 .author')->text()));
|
||||||
$game->title = trim($gameBlock->filter('.cell-2 h3 a')->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 = "";
|
$game->description = "";
|
||||||
|
|
||||||
$this->loadStr($this->get_text($game->url), []);
|
$this->loadStr($this->get_text($game->url));
|
||||||
$game->description = $this->dom->filter('.description')->first()->text();
|
$game->description = $this->dom->filter('.description')->first()->text();
|
||||||
|
|
||||||
$this->output .= $game->print();
|
$this->output .= $game->print();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public function checkPage($url) {
|
public function checkPage($url) {
|
||||||
return (strpos($url,'http://kvester.ru/game/') !== FALSE);
|
return (strpos($url, $this->baseUrl.'/game/') !== FALSE);
|
||||||
}
|
}
|
||||||
public function page($url) {
|
public function page($url) {
|
||||||
$game = new Game;
|
$game = new Game;
|
||||||
$game->url = $url;
|
$game->url = $url;
|
||||||
|
$game_id = (int) str_replace($this->baseUrl.'/game/', '', $url);
|
||||||
$game->platform = 'Квестер';
|
$game->platform = 'Квестер';
|
||||||
$game->title = trim($this->dom->filter(".qt-in-1 h2")->first()->text());
|
$game->title = trim($this->dom->filter(".qt-in-1 h2")->first()->text());
|
||||||
$game->author = trim($this->dom->filter('.quest-info .author a')->text());
|
$game->author = trim($this->dom->filter('.quest-info .author a')->text());
|
||||||
|
@ -40,7 +42,17 @@ class Kvester extends Source {
|
||||||
'd.m.y',
|
'd.m.y',
|
||||||
trim($this->dom->filter('.quest-info .date')->first()->text())
|
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->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;
|
return $game;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue