本文整理汇总了PHP中DOMDocument::loadHtmlFile方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMDocument::loadHtmlFile方法的具体用法?PHP DOMDocument::loadHtmlFile怎么用?PHP DOMDocument::loadHtmlFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMDocument
的用法示例。
在下文中一共展示了DOMDocument::loadHtmlFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadPage
protected function loadPage()
{
$bOldSetting = libxml_use_internal_errors(true);
libxml_clear_errors();
$oHtml = new DOMDocument();
$oHtml->loadHtmlFile($this->buildUrl());
libxml_clear_errors();
libxml_use_internal_errors($bOldSetting);
return $oHtml;
}
示例2: get_graph
private function get_graph($url)
{
//fetch html content from web source and filter to meta data
$dom = new DOMDocument();
@$dom->loadHtmlFile($url);
$tags = $dom->getElementsByTagName('meta');
//set open graph search tag and return object
$og_pattern = '/^og:/';
$graph_content = array();
//for each open graph tag, store in return object as property : content
foreach ($tags as $element) {
if (preg_match($og_pattern, $element->getAttribute('property'))) {
$graph_content[preg_replace($og_pattern, '', $element->getAttribute('property'))] = $element->getAttribute('content');
}
}
//store all open graph tags
return $graph_content;
}
示例3: DOMDocument
$pages = $pages0 + 1;
}
//USERS
$file_string2 = file_get_contents($url);
preg_match('#<b>(.*?)</b>#i', $file_string2, $users);
$nbusers = str_replace(",", "", $users[1]);
//RATIO
$ratio = $nbreviews / $nbusers;
//INITIALIZATION
$add = 0;
//LOOP REVIEWS SCRAPING
for ($i = 1; $i <= $pages; $i++) {
$oldSetting = libxml_use_internal_errors(true);
libxml_clear_errors();
$html = new DOMDocument();
$html->loadHtmlFile($url . '/reviews/?page=' . $i);
$xpath = new DOMXPath($html);
$links = $xpath->query("//div[contains(@class, 'review')and \n not(contains(@class,'reply'))]");
//Do not include the comments written by the addon's developer
$return = array();
foreach ($links as $item) {
$newDom = new DOMDocument();
$newDom->appendChild($newDom->importNode($item, true));
$xpath = new DOMXPath($newDom);
$review = str_replace("\"", "", trim($xpath->query("//p[@class='review-body']")->item(0)->nodeValue));
//$review = "\"".$review."\",";
$return[] = array($review);
}
// REVIEWS ARRAY
$return = print_r($return, true);
$return = htmlspecialchars($return);