Archived
1
0
Fork 0
This repository has been archived on 2020-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
news-script/Source/Urq.php

34 lines
1.3 KiB
PHP

<?php
namespace Source;
use \Game;
class Urq extends Source {
public $title = "Библиотека URQ";
protected function parse() {
$text = $this->get_text('http://urq.plut.info/node/209');
$this->loadStr($text);
unset($text);
$games = $this->dom->filter('.view-NewGames tr')->each(function($gameBlock) {
$game = new Game;
$game->author = trim($gameBlock->filter('.views-field-taxonomy-vocabulary-2')->first()->text());
$game->title = trim($gameBlock->filter('.views-field-title')->text());
$game->url = trim($gameBlock->filter('.views-field-title a')->attr('href'));
$this->output .= $game->print();
});
}
public function checkPage($url) {
return (strpos($url,'http://urq.plut.info/node/') !== FALSE);
}
public function page($url) {
$game = new Game;
$game->url = $url;
$gameBlock = $this->dom->filter('.content');
$game->author = trim($gameBlock->filter('.field-name-taxonomy-vocabulary-2 a')->first()->text());
$game->title = trim($this->dom->filter('h1.title')->first()->text());
$game->description = $gameBlock->filter('.field-type-text-with-summary .field-items span.field-item')->first()->text();
$game->platform = $gameBlock->filter('.field-name-taxonomy-vocabulary-5 .field-items span.field-item a')->first()->text();
return $game;
}
}