Home  >  Article  >  php教程  >  Codeigniter的dom类

Codeigniter的dom类

PHP中文网
PHP中文网Original
2016-05-25 17:15:361215browse

利用simple_html_dom dom类为CI修改的一个类库,可以像JS一样对HTML元素进行分析,适合与抓取网页时,对网页数据进行的分析。 

修改: 
把simple_html_dom批量替换为CI_Simple_html_dom。 
放置在application\libraries下 

1. [代码]php代码 

function index()  
    {  
        //$this->load->view('welcome_message');  
        $this->load->library('Simple_html_dom');  
          
        $html = file_get_html('http://localhost/test.htm');  
        foreach($html->find('a') as $e)   
        echo $e->href . &#39;<br>&#39;;  
    }

                   


                   

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn