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/Steam.php
2017-10-07 19:08:42 +07:00

46 lines
1.2 KiB
PHP

<?php
namespace Source;
use \Game;
class Steam extends Source {
public $title = "Steam";
protected function parse_tag($tag) {
$url = 'http://store.steampowered.com/search/';
$url .= '?'.http_build_query([
'sort_by' => 'Released_DESC',
'term' => $tag,
'displayterm' => $tag,
'category1' => 998, // only games
]);
$text = $this->get_text($url);
try {
$this->dom->loadStr($text, []);
} catch (Exception $e) {
echo $e->getMessage();
echo $e->getTraceAsString();
return "";
}
unset($text);
$games = $this->dom->find('#search_result_container a.search_result_row');
foreach ($games as $gameLink) {
$url = $gameLink->getAttribute('href');
$text = $this->get_text($url);
try {
$this->dom->loadStr($text, []);
} catch (Exception $e) {
continue;
}
unset($text);
$game = new Game;
$game->title = $this->dom->find('.apphub_AppName')->innerHtml;
$game->description = $this->dom->find('.game_description_snippet')->innerHtml;
$game->url = $url;
$this->output .= $game->print();
}
}
protected function parse() {
$this->parse_tag("text-based");
}
}