I'm trying to use HTML DOM Parser to get the image source of the "main" product image no matter what product page the parser is being pointed to.
On every page it seems that that image has the id "landingImage". You would think that this should do the trick:
$finalarray[$i][2] = $html->find('img[id="landingImage"]', 0)->src;
But no such luck.
I also tried
foreach($html->find('img') as $e)
if (strpos($e,'landingImage') !== false) {
$finalarray[$i][2] = $e->src;
}
I noticed that usually the image source has SY300 or SX300 so I did this:
foreach($html->find('img') as $e)
if (strpos($e,'SX300') !== false) {
$finalarray[$i][2] = $e->src;
}
else if (strpos($e,'SY300') !== false) {
$finalarray[$i][2] = $e->src;
}
Unfortunately some image source links don't contain that, example:
http://www.amazon.com/gp/product/B001O21H00/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B001O21H00&linkCode=as2&tag=bmref-20