用PHP中的“HTML标记”提取所有div内容

用PHP中的“HTML标记”提取所有div内容,php,html,parsing,web-scraping,web-crawler,Php,Html,Parsing,Web Scraping,Web Crawler,我必须提取一些具有css类的特定div的内容,例如整个内容。但重要的是用HTML标记获取内容 $ch = curl_init("http://hihi2.com/2014/04/14/p215331.html"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $cl = curl_exec($ch); $dom = new DOMDocument('1.0', "UTF-8"); @$dom->loadHTML('<meta htt

我必须提取一些具有css类的特定div的内容,例如整个内容。但重要的是用HTML标记获取内容

$ch = curl_init("http://hihi2.com/2014/04/14/p215331.html");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$cl = curl_exec($ch);
$dom = new DOMDocument('1.0', "UTF-8");
@$dom->loadHTML('<meta http-equiv="content-type" content="text/html; charset=utf-8">'.$cl);
$xpath = new DomXPath($dom);

$title = $xpath->query("//div[@class='float_right']/span/a");


echo "<pre>";
foreach ($title as $key=>$value){
   $titlear[$key] = ($value->nodeValue);
}

它将整个内容作为文本提供给我,我需要被其标记包围的文本。

@RahilWazir,它在他的代码的URL上。。此URL具有所需的div,这是一个完整的css类-content@Ihsanullahkhan提供的链接没有任何完整内容class@RahilWazir抱歉,类名为entry-content。此链接可能会有所帮助:重要的是使用xpath。