Rumah >pembangunan bahagian belakang >tutorial php >使用DOMDocument抓取数据 并归类
使用DOMDocument抓取数据 并分类
http://smart-phones.biyixia.com/node/1013
<?php<br />/**<br /> * Created by PhpStorm.<br /> * User: Admin<br /> * Date: 13-11-14<br /> * Time: 下午10:42<br /> */<br />$link[]=array();<br /><br />$page_url='http://smart-phones.biyixia.com/node/1013';<br />//$content=get_data($page_url);<br />$doc= new DOMDocument();<br />@$doc->loadHTMLFile($page_url);<br /><br />$div_contents = $doc->getElementsByTagName('div');<br /><br />print_r($div_contents);<br />foreach($div_contents as $div_content ){<br /> $items = $div_content->getAttribute("class");<br /> $itme_value = $items->nodeValue;<br />}<br />echo $items_value;