You can extract a certain div from the $output by locating it first with strpos() and then finding the end of that div with strpos() then using substr() to extract that div only. It is not an easy task running through the code of the search page to find your particular div and it would work best if you had some type of unique value to it which meant you could search directly for it in the $output variable.
Just as an example of substr() and strpos() usage:
Code: Select all
$findme = '<div class="unique">';
$pos = strpos($output, $findme) + strlen($findme);
$id_start = substr($output, $pos);
$id_strip = strpos($id_start, "</div>", 1);
$id_end = substr($id_start, 0, $id_strip);
echo $id_end;
Its not a simple task to do unfortunately and you really need to research the use of these functions but to answer your question I am not aware of another common way to extract only a certain <div>.
You will run into complications when you have no unique <div> it you come accross more than one so you have to code which div it is you want to extract otherwise the code will stop at the first div if finds. You will also have to deal with the potential HTML Tags embedded within your content because if you copy these with the content you will then display this on your site which you might not want.
I suggest looking into that previous post I linked for you just incase you need to strip the tags from the content or at least ignore them from the count.
Best wishes