Codeigniter的dom类用法实例

前端之家收集整理的这篇文章主要介绍了Codeigniter的dom类用法实例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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


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


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


@H
403_0@修改


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


<div class="jb51code">
<pre class="brush: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 . '
';
}

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

猜你在找的PHP相关文章