当前位置: 首页>>代码示例>>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;未经允许,请勿转载。