Home >Backend Development >PHP Tutorial >使用DOMDocument抓取数据 并归类

使用DOMDocument抓取数据 并归类

WBOY
WBOYOriginal
2016-06-13 11:40:47891browse

使用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;


我想要的效果是 比如: 手机尺寸=>XXXX
                  产品价格=>XXXX

跪求指导!!!

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