本文整理汇总了PHP中DomDocument::loadHtmlFile方法的典型用法代码示例。如果您正苦于以下问题:PHP DomDocument::loadHtmlFile方法的具体用法?PHP DomDocument::loadHtmlFile怎么用?PHP DomDocument::loadHtmlFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomDocument
的用法示例。
在下文中一共展示了DomDocument::loadHtmlFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: metascore
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: key
$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: DomXpath
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