<?php
$htmlget = new DOMDocument();
@$htmlget->loadHtmlFile(http://www.amazon.com);
$xpath = new DOMXPath( $htmlget);
$nodelist = $xpath->query( "//img/@src" );
foreach ($nodelist as $images){
$value = $images->nodeValue;
}
?>
i got all images but how do i get the information around the same element the image is in? for example, on amazon.com, theres a the kindle. i have the picture now but need the information around such as the price description…
thanks
It depends on the markup of the requested page, here an example for getting the price on amazon:
But however, you shouldn’t parse pages that way. If they want to provide you some information, the ususally have an API. If not, they don’t want you to grab anything. Parsing that way is not reliable, the markup of the requested page can change every second(you may open a door for exploits too). It also may not be legal .