Anivisual and Apero updates
This commit is contained in:
parent
39f3cee99a
commit
1b0c20b975
|
@ -23,15 +23,14 @@ class Anivisual extends Source {
|
||||||
$text = $this->get_text('http://anivisual.net/stuff/1');
|
$text = $this->get_text('http://anivisual.net/stuff/1');
|
||||||
$this->loadStr($text);
|
$this->loadStr($text);
|
||||||
unset($text);
|
unset($text);
|
||||||
$games = $this->dom->filter('.entryBlock');
|
$this->dom->filter('.entryBlock')->each(function($gameBlock) {
|
||||||
foreach ($games as $gameBlock) {
|
|
||||||
$date = trim($gameBlock->filter('.icon-calendar')->text());
|
$date = trim($gameBlock->filter('.icon-calendar')->text());
|
||||||
foreach ($this->months as $ruM => $enM) {
|
foreach ($this->months as $ruM => $enM) {
|
||||||
$date = str_replace($ruM, $enM, $date);
|
$date = str_replace($ruM, $enM, $date);
|
||||||
}
|
}
|
||||||
$date = \DateTime::createFromFormat('d F Y', $date);
|
$date = \DateTime::createFromFormat('d F Y', $date);
|
||||||
$date = $date->format('U');
|
$date = $date->format('U');
|
||||||
if ($date < $this->period) continue;
|
if ($date < $this->period) return;
|
||||||
$game = new Game;
|
$game = new Game;
|
||||||
$link = $gameBlock->filter('.novel-ttl a')->first();
|
$link = $gameBlock->filter('.novel-ttl a')->first();
|
||||||
$game->title = htmlspecialchars_decode($link->innerHtml);
|
$game->title = htmlspecialchars_decode($link->innerHtml);
|
||||||
|
@ -41,7 +40,7 @@ class Anivisual extends Source {
|
||||||
$games[] = $game;
|
$games[] = $game;
|
||||||
|
|
||||||
$this->output .= $game->print();
|
$this->output .= $game->print();
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
public function checkPage($url) {
|
public function checkPage($url) {
|
||||||
return (strpos($url,'http://anivisual.net/stuff/') !== FALSE);
|
return (strpos($url,'http://anivisual.net/stuff/') !== FALSE);
|
||||||
|
|
|
@ -12,27 +12,26 @@ class Apero extends Source {
|
||||||
protected function parse() {
|
protected function parse() {
|
||||||
$text = $this->get_text('http://apero.ru/Текстовые-игры/Песочница');
|
$text = $this->get_text('http://apero.ru/Текстовые-игры/Песочница');
|
||||||
$text = mb_convert_encoding($text, 'UTF-8', 'auto');
|
$text = mb_convert_encoding($text, 'UTF-8', 'auto');
|
||||||
$this->dom->loadStr($text, []);
|
$this->loadStr($text);
|
||||||
$this->parsePage();
|
$this->parseIndex();
|
||||||
$text = $this->get_text('http://apero.ru/Текстовые-игры');
|
$text = $this->get_text('http://apero.ru/Текстовые-игры');
|
||||||
$text = mb_convert_encoding($text, 'UTF-8', 'auto');
|
$text = mb_convert_encoding($text, 'UTF-8', 'auto');
|
||||||
$this->dom->loadStr($text, []);
|
$this->loadStr($text);
|
||||||
$this->parsePage();
|
$this->parseIndex();
|
||||||
}
|
}
|
||||||
protected function parsePage()
|
protected function parseIndex()
|
||||||
{
|
{
|
||||||
$formatter = new \IntlDateFormatter( 'ru', \IntlDateFormatter::LONG, \IntlDateFormatter::NONE );
|
$this->dom->filter('.tabled-game-block')->each(function($gameBlock){
|
||||||
$games = $this->dom->find('.tabled-game-block');
|
$formatter = new \IntlDateFormatter( 'ru', \IntlDateFormatter::LONG, \IntlDateFormatter::NONE );
|
||||||
foreach ($games as $gameBlock) {
|
$date = trim($gameBlock->filter('.game-updated-block')->text(), "() \t\n\r\0\x0B");
|
||||||
$date = trim($gameBlock->find('.game-updated-block')->innerHtml, "() \t\n\r\0\x0B");
|
|
||||||
$date = $formatter->parse($date);
|
$date = $formatter->parse($date);
|
||||||
if ($date < $this->period) continue;
|
if ($date < $this->period) return;
|
||||||
$game = new Game;
|
$game = new Game;
|
||||||
$game->author = trim($gameBlock->find('.game-author-block')[0]->find('a')->innerHtml);
|
$game->author = trim($gameBlock->filter('.game-author-block:first-child a')->text());
|
||||||
$game->title = trim($gameBlock->find('h2')[0]->find('a')[0]->innerHtml);
|
$game->title = trim($gameBlock->find('h2:first-child a:first-child')->first()->text());
|
||||||
$game->url = trim($gameBlock->find('h2')[0]->find('a')[0]->getAttribute('href'));
|
$game->url = trim($gameBlock->find('h2:first-child a:first-child')->first()->getAttribute('href'));
|
||||||
$game->description = trim($gameBlock->find('.game-desc-block')[0]->innerHtml);
|
$game->description = trim($gameBlock->find('.game-desc-block')->first()->text());
|
||||||
$this->output .= $game->print();
|
$this->output .= $game->print();
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue