Home > Backend Development > PHP Tutorial > Codeigniter的dom类用法实例_php实例

Codeigniter的dom类用法实例_php实例

WBOY
Release: 2016-06-07 17:12:20
Original
928 people have browsed it

本文实例讲述了Codeigniter的dom类用法。分享给大家供大家参考。具体分析如下:

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

类库下载地址: http://sourceforge.net/projects/simplehtmldom/

修改:

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

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 . '<br>'; 
}

Copy after login

希望本文所述对大家基于Codeigniter的php程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template