hi, duke
can you tell me were did you get $books variables, because you did not define or assign a value on it ..and you execute foreach loop of $book variables.
I think code should be
$doc = new DOMDocument();
// Get the sourcecode of the domain
@$doc->loadHTMLFile($domain);
//here we are collecting all div tags from web page
$books = $doc->getElementsByTagName('div');
foreach($books as $div)
{
if($div->getAttribute('class') == "price"){
echo $class->nodeValue;
}
// and we can do this below code also
if (strpos($class, 'price') !== false)
{
echo $class->nodeValue;
}
}
happy coding!