Начало парсеров
This commit is contained in:
parent
9019e9c26e
commit
90d0e020f1
1
Game.php
1
Game.php
|
@ -6,6 +6,7 @@ class Game {
|
|||
public $author;
|
||||
public $description;
|
||||
public $date;
|
||||
public $image;
|
||||
public function print() {
|
||||
$converter = new HtmlConverter();
|
||||
if (STYLE === 'RUS') {
|
||||
|
|
|
@ -42,10 +42,41 @@ class Anivisual extends Source {
|
|||
$link = $gameBlock->find('.novel-ttl a')[0];
|
||||
$game->title = $link->innerHtml;
|
||||
$game->url = 'http://anivisual.net'.$link->getAttribute('href');
|
||||
$game->description = $gameBlock->find('span')->first()->text;
|
||||
|
||||
$games[] = $game;
|
||||
|
||||
$this->output .= $game->print();
|
||||
}
|
||||
}
|
||||
public function checkPage($url) {
|
||||
return (strpos($url,'http://anivisual.net/stuff/') !== FALSE);
|
||||
}
|
||||
public function page($url) {
|
||||
$text = $this->get_text($url);
|
||||
try {
|
||||
$this->dom->loadStr($text, []);
|
||||
} catch (\Exception $e) {
|
||||
echo $e->getMessage();
|
||||
echo $e->getTraceAsString();
|
||||
return "";
|
||||
}
|
||||
unset($text);
|
||||
$game = new Game;
|
||||
$game->url = $url;
|
||||
$gameBlock = $this->dom->find('#casing-box');
|
||||
try {
|
||||
$date = trim($gameBlock->find('.icon-calendar')->first()->text);
|
||||
foreach ($this->months as $ruM => $enM) {
|
||||
$date = str_replace($ruM, $enM, $date);
|
||||
}
|
||||
$date = \DateTime::createFromFormat('d F Y', $date);
|
||||
$date = $date->format('U');
|
||||
$game->date = $date;
|
||||
unset($date);
|
||||
} catch (\Exception $e) {}
|
||||
$game->title = $gameBlock->find('h1.logo')->text;
|
||||
// $game->description = $this->dom->find('#content > section > span')->text;
|
||||
return $game;
|
||||
}
|
||||
}
|
||||
|
|
6
wiki.php
6
wiki.php
|
@ -15,6 +15,9 @@ if (!isset($argv[1])) {
|
|||
$url = strtolower($argv[1]);
|
||||
$game = new Game;
|
||||
|
||||
function wikipage($game) {
|
||||
var_dump($game);
|
||||
}
|
||||
function check($classname) {
|
||||
global $game;
|
||||
global $url;
|
||||
|
@ -23,6 +26,9 @@ function check($classname) {
|
|||
$cl = (new $cname());
|
||||
if ($cl->checkPage($url)) {
|
||||
$game = $cl->page($url);
|
||||
if ($game) {
|
||||
wikipage($game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue