Archived
1
0
Fork 0

Anivisual and Apero updates

This commit is contained in:
Alexander Yakovlev 2018-03-25 02:22:00 +07:00
parent 39f3cee99a
commit 1b0c20b975
2 changed files with 17 additions and 19 deletions

View file

@ -23,15 +23,14 @@ class Anivisual extends Source {
$text = $this->get_text('http://anivisual.net/stuff/1');
$this->loadStr($text);
unset($text);
$games = $this->dom->filter('.entryBlock');
foreach ($games as $gameBlock) {
$this->dom->filter('.entryBlock')->each(function($gameBlock) {
$date = trim($gameBlock->filter('.icon-calendar')->text());
foreach ($this->months as $ruM => $enM) {
$date = str_replace($ruM, $enM, $date);
}
$date = \DateTime::createFromFormat('d F Y', $date);
$date = $date->format('U');
if ($date < $this->period) continue;
if ($date < $this->period) return;
$game = new Game;
$link = $gameBlock->filter('.novel-ttl a')->first();
$game->title = htmlspecialchars_decode($link->innerHtml);
@ -41,7 +40,7 @@ class Anivisual extends Source {
$games[] = $game;
$this->output .= $game->print();
}
});
}
public function checkPage($url) {
return (strpos($url,'http://anivisual.net/stuff/') !== FALSE);

View file

@ -12,27 +12,26 @@ class Apero extends Source {
protected function parse() {
$text = $this->get_text('http://apero.ru/Текстовые-игры/Песочница');
$text = mb_convert_encoding($text, 'UTF-8', 'auto');
$this->dom->loadStr($text, []);
$this->parsePage();
$this->loadStr($text);
$this->parseIndex();
$text = $this->get_text('http://apero.ru/Текстовые-игры');
$text = mb_convert_encoding($text, 'UTF-8', 'auto');
$this->dom->loadStr($text, []);
$this->parsePage();
$this->loadStr($text);
$this->parseIndex();
}
protected function parsePage()
protected function parseIndex()
{
$formatter = new \IntlDateFormatter( 'ru', \IntlDateFormatter::LONG, \IntlDateFormatter::NONE );
$games = $this->dom->find('.tabled-game-block');
foreach ($games as $gameBlock) {
$date = trim($gameBlock->find('.game-updated-block')->innerHtml, "() \t\n\r\0\x0B");
$this->dom->filter('.tabled-game-block')->each(function($gameBlock){
$formatter = new \IntlDateFormatter( 'ru', \IntlDateFormatter::LONG, \IntlDateFormatter::NONE );
$date = trim($gameBlock->filter('.game-updated-block')->text(), "() \t\n\r\0\x0B");
$date = $formatter->parse($date);
if ($date < $this->period) continue;
if ($date < $this->period) return;
$game = new Game;
$game->author = trim($gameBlock->find('.game-author-block')[0]->find('a')->innerHtml);
$game->title = trim($gameBlock->find('h2')[0]->find('a')[0]->innerHtml);
$game->url = trim($gameBlock->find('h2')[0]->find('a')[0]->getAttribute('href'));
$game->description = trim($gameBlock->find('.game-desc-block')[0]->innerHtml);
$game->author = trim($gameBlock->filter('.game-author-block:first-child a')->text());
$game->title = trim($gameBlock->find('h2:first-child a:first-child')->first()->text());
$game->url = trim($gameBlock->find('h2:first-child a:first-child')->first()->getAttribute('href'));
$game->description = trim($gameBlock->find('.game-desc-block')->first()->text());
$this->output .= $game->print();
}
});
}
}