Skip to content

Instantly share code, notes, and snippets.

@dmnc-net
Created August 6, 2012 09:18
Show Gist options
  • Save dmnc-net/3272495 to your computer and use it in GitHub Desktop.
Save dmnc-net/3272495 to your computer and use it in GitHub Desktop.
ultimafund - page content crawler
<?php
/*
this is .htaccess file:
----------------------
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
*/
ini_set('error_reporting', E_ALL);
ini_set('display_errors',1);
function enableDebug() {
$scriptstarttime = microtime(true);
date_default_timezone_set('Europe/Prague'); // nutne kvuli fce date()
@(include_once ('lib_debug.php')) or die("FATAL ERROR: unsuccessful include call (lib_debug)!");
}
function getStringFromElement($html, $query){
$dom = new DOMDocument();
@$dom->loadHTML ($html);
$xpath = new DOMXPath($dom);
$elements = $xpath->query($query);
if ($elements) foreach ($elements as $element) {
foreach ($element->childNodes as $node) {
$value = $node->nodeValue;
// debug("getStringFromElement",$value);
if ($value) $array[] = rtrim ($value);
}
}
if (isset($array)) return $array;
}
$html = file_get_contents("http://www.ultimafund.com/statistics/");
$array = (getStringFromElement ($html,'/html/body/div[@id="main"]/div/section/div[2]/div/ul/li/span'));
//enableDebug();
//debug ($html, $array);
if (isset($_SERVER["QUERY_STRING"])) $period = strip_tags($_SERVER["QUERY_STRING"]); else $period = 0;
if (!isset($array[$period])) $period = 0;
die($array[$period]);
?>
@dmnc-net
Copy link
Author

ultimafund was a scam :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment