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

47 lines
1.3 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);
$game = new Game;
/*
$game->title = $gameData->title;
$game->author = $gameData->developer->display_name;
$game->date = $gameData->published_on;
$game->description = $descData->payload->metaDescription;
$game->url = 'https://gamejolt.com/games/'.$gameData->slug.'/'.$gameData->id;
if ($game->date < $this->period) {
continue;
}
*/
$this->output .= $game->print();
}
}
protected function parse() {
$this->parse_tag("text-based");
}
}