我正在使用 curl 功能从另一端获取信息,但它显示了网站的完整页面。我想根据班级名称显示内容。请让我知道我该怎么做?我正在使用以下代码:-
<?php
$curl = curl_init('http://www.insolvency.govt.nz/cms/search?SearchableText=smith');
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($curl);
$dom = new DOMDocument();
$res=$dom->loadHTML($result);
$divs = $dom->getElementsByTagName('div');
foreach($divs as $div) {
if ($div->getAttribute('id') === 'searchResult') {
echo $div->nodeValue;
}else{
echo "error";
}
}
?>