Парсер страниц Квестера
This commit is contained in:
parent
79f44c2cdc
commit
9a0248a8d9
|
@ -27,4 +27,20 @@ class Kvester extends Source {
|
||||||
$this->output .= $game->print();
|
$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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
25
Wikipage.php
25
Wikipage.php
|
@ -23,13 +23,20 @@ class Wikipage {
|
||||||
$this->game = $game;
|
$this->game = $game;
|
||||||
|
|
||||||
if (!$config['DUMMY']) {
|
if (!$config['DUMMY']) {
|
||||||
// Log in to a wiki
|
try {
|
||||||
$api = new MediawikiApi( $config['WIKI'] );
|
// Log in to a wiki
|
||||||
$api->login( new ApiUser( $config['WIKIUSER'], $config['WIKIPASSWORD'] ) );
|
$api = new MediawikiApi( $config['WIKI'] );
|
||||||
$services = new MediawikiFactory( $api );
|
$api->login( new ApiUser( $config['WIKIUSER'], $config['WIKIPASSWORD'] ) );
|
||||||
$this->api = $api;
|
$services = new MediawikiFactory( $api );
|
||||||
$this->services = $services;
|
$this->api = $api;
|
||||||
$this->fileUploader = $services->newFileUploader();
|
$this->services = $services;
|
||||||
|
$this->fileUploader = $services->newFileUploader();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
echo 'Ошибка соединения.'.PHP_EOL;
|
||||||
|
echo $e->getMessage();
|
||||||
|
echo $e->getTraceAsString();
|
||||||
|
$config['DUMMY'] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function create() {
|
public function create() {
|
||||||
|
@ -147,6 +154,10 @@ class Wikipage {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function exists($pagename) {
|
protected function exists($pagename) {
|
||||||
|
global $config;
|
||||||
|
if ($config['DUMMY']) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$page = $this->services->newPageGetter()->getFromTitle((string) $pagename);
|
$page = $this->services->newPageGetter()->getFromTitle((string) $pagename);
|
||||||
return !($page->getId() === 0);
|
return !($page->getId() === 0);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue