<?php
// Modified the cURL function to accept POST parameters and a cookiejar file
// You will actually need to use a cookie jar because the cookie is not static
// Using a cookie jar allows the server to change the cookie as needed and the changed cookie is sent back to the server.
function request($url, $params=array(), $cookiejar="") {
$ch = curl_init();
$curlOpts = array(
CURLOPT_URL => $url,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true
);
if (!empty($params)) {
// If POST values are given, send that shit too
$curlOpts[CURLOPT_POST] = true;
$curlOpts[CURLOPT_POSTFIELDS] = $params;
}
if (!empty($cookiejar)) {
if(!file_exists($cookiejar)){
echo 'Cookie file missing. please create it first.'; exit;
}else if(!is_writable($cookiejar)){
echo 'Cookie file not writable. chmod it to 777.'; exit;
}
curl_setopt($ch, CURLOPT_COOKIEJAR, realpath($cookiejar));
curl_setopt($ch, CURLOPT_COOKIEFILE, realpath($cookiejar));
}
curl_setopt_array($ch, $curlOpts);
$answer = curl_exec($ch);
// If there was an error, show it
if (curl_error($ch)) die(curl_error($ch));
curl_close($ch);
return $answer;
}
// The url you're trying to access
$url = "http://store.steampowered.com/app/223470";
// The url that gives us the cookie
$cookie_url = "http://store.steampowered.com/agecheck/app/223470/";
// The POST parameters that are sent to the server when requesting a cookie
$params = array("ageDay"=>1, "ageMonth"=>"January", "ageYear"=>"1915", "snr"=>"1_agecheck_agecheck__age-gate");
// This request just give us a cookie.
request($cookie_url, $params, "cookiejar");
// And this request is that page you need
$html = request($url, array(), "cookiejar");
// Domdoc stuff that we already discussed
$dom = new domDocument;
libxml_use_internal_errors(true);
$dom->loadHTML($html);
$classname="game_description_snippet";
$finder = new DomXPath($dom);
$spaner = $finder->query("//*[contains(@class, '$classname')]");
foreach ($spaner as $spane) {
$mo = $spane->nodeValue;
echo $mo;
}
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/Ws7JP:8
Stack trace:
#0 /in/Ws7JP(50): request('http://store.st...', Array, 'cookiejar')
#1 {main}
thrown in /in/Ws7JP on line 8
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/Ws7JP:8
Stack trace:
#0 /in/Ws7JP(50): request('http://store.st...', Array, 'cookiejar')
#1 {main}
thrown in /in/Ws7JP on line 8
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Call to undefined function curl_init() in /in/Ws7JP on line 8
Process exited with code 255.