當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DOMDocument::loadHtmlFile方法代碼示例

本文整理匯總了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;
 }
開發者ID:maxwroc,項目名稱:PHP,代碼行數:10,代碼來源:Parser.php

示例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;
 }
開發者ID:spaceone,項目名稱:programming-social-applications,代碼行數:18,代碼來源:OpenGraph.php

示例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);
開發者ID:netconstructor,項目名稱:ScrAPI-1,代碼行數:31,代碼來源:scrapifox.php


注:本文中的DOMDocument::loadHtmlFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。