public function metascore($type = "game", $name, $platform = NULL)
 {
     if (!$name) {
         throw new Exception("No parameters.");
     }
     $name = self::stripUrl($name);
     if ($platform) {
         $platform = self::stripUrl($platform);
     }
     $dom = new DomDocument();
     if ($type != ("movie" || "tv")) {
         $dom->loadHtmlFile("http://www.metacritic.com/{$type}/{$platform}/{$name}/");
         //replace this with Metacritics JSON search
     } else {
         $dom->loadHtmlFile("http://www.metacritic.com/{$type}/{$name}/");
         //replace this with Metacritics JSON search
     }
     $xpath = new DOMXpath($dom);
     $nodes = $xpath->evaluate("//span[@property='v:average']");
     if ($nodes) {
         return $nodes->item(0)->nodeValue;
     } else {
         throw new Exception("Could not find Metascore.");
     }
 }
예제 #2
0
            			$okres =false;
            			$kraj = false;
            			$obyvatelov = 0;
            			
            			if(isset($name2okresakraj[$name])){
            				$okres = key($name2okresakraj[$name]);
            				$kraj = key($name2okresakraj[$name][$okres]);
            				$obyvatelov = reset($name2okresakraj[$name][$okres]);
            			}/**/
        }
        // psc[psc][clearobec]
    }
}
// spracovanie kosic
$ke = array();
if ($dom = @DomDocument::loadHtmlFile("kosice-psc-na-mestsku-cast.htm")) {
    $xpath = new DomXpath($dom);
    $i = 0;
    foreach ($xpath->query("//table[@id='maintable']/tr") as $row) {
        $i++;
        if ($i == 1) {
            continue;
        }
        $cast = $xpath->query("td[2]", $row)->item(0)->nodeValue;
        $name = Texts::clear("kosice-" . $cast);
        $psc = str_replace(" ", "", $xpath->query("td[3]", $row)->item(0)->nodeValue);
        if (isset($name2okresakraj[$name])) {
            $okres = key($name2okresakraj[$name]);
            $kraj = key($name2okresakraj[$name][$okres]);
            $obyvatelov = reset($name2okresakraj[$name][$okres]);
            @($pscdata[$psc][$name][$okres][$kraj] = $obyvatelov);
예제 #3
0
if ($dom = @DomDocument::loadHtmlFile("ulice-ba.html")) {
    $xpath = new DomXpath($dom);
    $i = 0;
    foreach ($xpath->query("//table/tbody/tr") as $row) {
        $i++;
        //if($i == 1) continue;
        if (!$xpath->query("td[4]", $row)->item(0)) {
            continue;
        }
        $cast = $xpath->query("td[2]", $row)->item(0)->nodeValue;
        $name = Texts::clear("bratislava-" . $cast);
        $name = normalize_city_name($name);
        @$pocetulic[$name]++;
    }
}
if ($dom = @DomDocument::loadHtmlFile("ulice-ba.html")) {
    $xpath = new DomXpath($dom);
    $i = 0;
    foreach ($xpath->query("//table/tbody/tr") as $row) {
        $i++;
        //if($i == 1) continue;
        if (!$xpath->query("td[4]", $row)->item(0)) {
            continue;
        }
        $cast = $xpath->query("td[2]", $row)->item(0)->nodeValue;
        $name = Texts::clear("bratislava-" . $cast);
        $name = normalize_city_name($name);
        $psc = str_replace(" ", "", $xpath->query("td[4]", $row)->item(0)->nodeValue);
        $psc = str_replace("O", "0", $psc);
        if ($pos = strpos($psc, ",")) {
            //zober iba prve psc na tej ulici