2017-02-16 08:39:00 +02:00
|
|
|
<?php
|
|
|
|
namespace Source;
|
|
|
|
|
|
|
|
use \Game;
|
|
|
|
|
|
|
|
class Textadventures extends Source {
|
|
|
|
public $title = "Textadventures.co.uk";
|
|
|
|
protected function parse() {
|
2017-07-13 18:07:14 +03:00
|
|
|
$text = $this->get_text('http://textadventures.co.uk/games/latest');
|
|
|
|
$this->dom->loadStr($text, []);
|
|
|
|
unset($text);
|
2017-02-16 08:39:00 +02:00
|
|
|
$games = $this->dom->find('.games-item');
|
|
|
|
foreach ($games as $gameBlock) {
|
|
|
|
$game = new Game;
|
|
|
|
$game->url = 'http://textadventures.co.uk'.$gameBlock->find('.games-title a')->getAttribute('href');
|
2017-03-10 08:47:28 +02:00
|
|
|
$lines = $this->dom->find('.game_info_panel_widget tr');
|
2017-02-16 08:39:00 +02:00
|
|
|
$game->title = $gameBlock->find('.games-title a')->innerHtml;
|
|
|
|
$date = strtotime($gameBlock->find('.games-date')->innerHtml);
|
|
|
|
if ($date < $this->period) continue;
|
2017-03-10 08:47:28 +02:00
|
|
|
$game_page = new \PHPHtmlParser\Dom;
|
2017-07-13 18:07:14 +03:00
|
|
|
$text = $this->get_text($game->url);
|
|
|
|
$game_page->loadStr($text, []);
|
|
|
|
unset($text);
|
2017-03-10 08:47:28 +02:00
|
|
|
try {
|
|
|
|
$game->author = str_replace('by ', '', $game_page->find('h1 small')->innerHtml);
|
2017-12-29 01:53:58 +02:00
|
|
|
$desc = $game_page->find('.col-md-12 .col-md-9 .col-md-7')[0];
|
2017-03-10 08:47:28 +02:00
|
|
|
if ($desc) {
|
2017-12-29 01:53:58 +02:00
|
|
|
$play = $desc->find('.play-buttons');
|
2017-03-10 08:47:28 +02:00
|
|
|
$desc = strip_tags($desc->innerHtml);
|
2017-12-29 01:53:58 +02:00
|
|
|
$game->description = trim(str_replace(strip_tags($play->innerHtml), '', $desc));
|
2017-03-10 08:47:28 +02:00
|
|
|
}
|
2017-10-26 14:44:32 +03:00
|
|
|
} catch (\Exception $e) {} // probably a 18+ game, no info on game page
|
2017-02-16 08:39:00 +02:00
|
|
|
|
|
|
|
$this->output .= $game->print();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|