0

I Would like to scrape images from this page http://www.ikea.com/us/en/catalog/products/S59163189/

The markup for displaying the images are like this:

 <div id="moreImgThumbContainer">
    <div class="imageThumb" id="imageThumb_0">
        <a href="javascript:void(0);" id="imageThumbLink_0" class="active">
            <img src="/PIAimages/0386819_PE559167_S3.JPG" onclick="irwStatThumbImgClickedFromPIP();" onmouseover="addOpacityEffect(this.id);" onmouseout="rmvOpacityEffect(this.id);" id="imgID_0" style="opacity: 10;">
        </a> 
    </div>



 <div class="imageThumb" id="imageThumb_1">
        <a href="javascript:void(0);" id="imageThumbLink_1">
            <img src="/PIAimages/0449646_PE599007_S3.JPG" onclick="irwStatThumbImgClickedFromPIP();" onmouseover="addOpacityEffect(this.id);" onmouseout="rmvOpacityEffect(this.id);" id="imgID_1" style="opacity: 0.8;">
        </a>
    </div>
</div>

I tried with the html code, in a single page, it works.

foreach($html->find('img[id^=imgID]') as $img_link){
         $img_array[] = 'http://www.ikea.com'.$img_link->src;
         $images = implode(';', $img_array); 
}

How can I get src of each image in PHP html dom parser using this api http://simplehtmldom.sourceforge.net/ ?

Edit: I think that i found the cause of the problem, the images are loading with ajax and takes time to load.

Is there a solution to scrape them?

Any help please!

SUB0DH
  • 5,130
  • 4
  • 29
  • 46

1 Answers1

0

Try with jquery and Array#map function

var d  = $('.imageThumb').map(function (){
c =  $(this).children('a').children('img').attr('src');
return c;
}).get()

console.log(d.join(';'))
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="moreImgThumbContainer">
    <div class="imageThumb" id="imageThumb_0">
        <a href="javascript:void(0);" id="imageThumbLink_0" class="active">
            <img src="/PIAimages/0386819_PE559167_S3.JPG" onclick="irwStatThumbImgClickedFromPIP();" onmouseover="addOpacityEffect(this.id);" onmouseout="rmvOpacityEffect(this.id);" id="imgID_0" style="opacity: 10;">
        </a> 
    </div> 

    <div class="imageThumb" id="imageThumb_1">
        <a href="javascript:void(0);" id="imageThumbLink_1">
            <img src="/PIAimages/0449646_PE599007_S3.JPG" onclick="irwStatThumbImgClickedFromPIP();" onmouseover="addOpacityEffect(this.id);" onmouseout="rmvOpacityEffect(this.id);" id="imgID_1" style="opacity: 0.8;">
        </a>
    </div>
</div>
prasanth
  • 22,145
  • 4
  • 29
  • 53