Uzyskaj element według nazwy klasy za pomocą metody DOMdocument ()

Oto, co próbuję osiągnąć: pobrać wszystkie produkty na stronie i umieścić je w tablicy. Oto kod, którego używam:

$page2 = curl_exec($ch);
$doc = new DOMDocument();
@$doc->loadHTML($page2);
$nodes = $doc->getElementsByTagName('title');
$noders = $doc->getElementsByClassName('productImage');
$title = $nodes->item(0)->nodeValue;
$product = $noders->item(0)->imageObject.src;

Działa dla$title but nie dla produktu. Aby uzyskać informacje, w kodzie HTML tag img wygląda tak:

<img alt="" class="productImage" data-altimages="" src="xxxx">

Patrzyłem na to (PHP DOMDocument jak zdobyć element?) ale nadal nie rozumiem, jak to działa.

PS: Dostaję ten błąd:

Zadzwoń do niezdefiniowanej metodyDOMDocument::getElementsByclassName()

questionAnswers(3)

yourAnswerToTheQuestion