http://smart-phones.biyixia.com/node/1013
<?php/** * Created by PhpStorm. * User: Admin * Date: 13-11-14 * Time: 下午10:42 */$link[]=array();$page_url='http://smart-phones.biyixia.com/node/1013';//$content=get_data($page_url);$doc= new DOMDocument();@$doc->loadHTMLFile($page_url);$div_contents = $doc->getElementsByTagName('div');print_r($div_contents);foreach($div_contents as $div_content ){ $items = $div_content->getAttribute("class"); $itme_value = $items->nodeValue;}echo $items_value;
$link[]=array();$page_url='http://smart-phones.biyixia.com/node/1013';//$content=get_data($page_url);$doc= new DOMDocument();@$doc->loadHTMLFile($page_url);$xPath = new DOMXPath($doc);$div_tags = $xPath->evaluate("/html/body//div//@class");for($i=0;$i<$div_tags->length;$i++){ $div_tag=$div_tags->item($i); $div_contents=$div_tag->nodeValue; echo $div_contents; echo "<br>";}
<div class="col-xs-3 key">图像尺寸</div>
xpath はご存知ですが、まだ質問する必要がありますか?
firebug または同様のプラグインを使用して確認すると、xpath がわかります