Парсер страниц Квестера
This commit is contained in:
parent
79f44c2cdc
commit
9a0248a8d9
|
@ -27,4 +27,20 @@ class Kvester extends Source {
|
|||
$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;
|
||||
|
||||
if (!$config['DUMMY']) {
|
||||
// Log in to a wiki
|
||||
$api = new MediawikiApi( $config['WIKI'] );
|
||||
$api->login( new ApiUser( $config['WIKIUSER'], $config['WIKIPASSWORD'] ) );
|
||||
$services = new MediawikiFactory( $api );
|
||||
$this->api = $api;
|
||||
$this->services = $services;
|
||||
$this->fileUploader = $services->newFileUploader();
|
||||
try {
|
||||
// Log in to a wiki
|
||||
$api = new MediawikiApi( $config['WIKI'] );
|
||||
$api->login( new ApiUser( $config['WIKIUSER'], $config['WIKIPASSWORD'] ) );
|
||||
$services = new MediawikiFactory( $api );
|
||||
$this->api = $api;
|
||||
$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() {
|
||||
|
@ -147,6 +154,10 @@ class Wikipage {
|
|||
* @return boolean
|
||||
*/
|
||||
protected function exists($pagename) {
|
||||
global $config;
|
||||
if ($config['DUMMY']) {
|
||||
return false;
|
||||
}
|
||||
$page = $this->services->newPageGetter()->getFromTitle((string) $pagename);
|
||||
return !($page->getId() === 0);
|
||||
}
|
||||
|
|
Reference in a new issue