steam parser improvements
This commit is contained in:
parent
95af2c5ec9
commit
5ab2e302f2
|
@ -2,6 +2,7 @@
|
||||||
namespace Source;
|
namespace Source;
|
||||||
|
|
||||||
use \Game;
|
use \Game;
|
||||||
|
use \PHPHtmlParser\Dom;
|
||||||
|
|
||||||
class Steam extends Source {
|
class Steam extends Source {
|
||||||
public $title = "Steam";
|
public $title = "Steam";
|
||||||
|
@ -25,14 +26,17 @@ class Steam extends Source {
|
||||||
$games = $this->dom->find('#search_result_container a.search_result_row');
|
$games = $this->dom->find('#search_result_container a.search_result_row');
|
||||||
foreach ($games as $gameLink) {
|
foreach ($games as $gameLink) {
|
||||||
$url = $gameLink->getAttribute('href');
|
$url = $gameLink->getAttribute('href');
|
||||||
$game = new Game;
|
$url = substr($url,0,strpos($url, '?')); // remove query string
|
||||||
|
game = new Game;
|
||||||
$game->url = $url;
|
$game->url = $url;
|
||||||
try {
|
try {
|
||||||
$text = $this->get_text($url);
|
$text = $this->get_text($url);
|
||||||
|
$this->dom = new Dom;
|
||||||
$this->dom->loadStr($text, []);
|
$this->dom->loadStr($text, []);
|
||||||
|
var_dump($text);
|
||||||
unset($text);
|
unset($text);
|
||||||
$name = $this->dom->find('.apphub_AppName');
|
$name = $this->dom->find('div.apphub_AppName');
|
||||||
$description = $this->dom->find('.game_description_snippet');
|
$description = $this->dom->find('meta[property=og:description]');
|
||||||
try {
|
try {
|
||||||
$game->title = $name->innerHtml;
|
$game->title = $name->innerHtml;
|
||||||
$game->description = $description->innerHtml;
|
$game->description = $description->innerHtml;
|
||||||
|
@ -44,6 +48,7 @@ class Steam extends Source {
|
||||||
echo $e->getTraceAsString();
|
echo $e->getTraceAsString();
|
||||||
}
|
}
|
||||||
$this->output .= $game->print();
|
$this->output .= $game->print();
|
||||||
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected function parse() {
|
protected function parse() {
|
||||||
|
|
Reference in a new issue