I am trying to pull the price and seller from the amazon offer listing pages found at:
http://www.amazon.com/gp/offer-listing/B002UYSHMM
I can get the price by using:
$ret['Retail'] = $html->find('span[class="price"]', 0)->innertext;
This pulls the first price in the offer listing
I tried to pull the matching seller of the first price by using the below to get the alt value from the img which contains the seller name:
$ret['SoldBy'] = $html->find('ul.sellerInformation img', 0)->getAttribute('alt');
It worked for the first one but as I went down it started missing sellers and even missing prices in some cases.
Can anyone tell why it would miss sellers and even jump around on prices? All I did to get additional sellers is:
$ret['Retail2'] = $html->find('span[class="price"]', 1)->innertext;
$ret['SoldBy2'] = $html->find('ul.sellerInformation img', 1)->getAttribute('alt');
$ret['Retail3'] = $html->find('span[class="price"]', 2)->innertext;
$ret['SoldBy3'] = $html->find('ul.sellerInformation img', 2)->getAttribute('alt');
$ret['Retail4'] = $html->find('span[class="price"]', 3)->innertext;
$ret['SoldBy4'] = $html->find('ul.sellerInformation img', 3)->getAttribute('alt');
$ret['Retail5'] = $html->find('span[class="price"]', 4)->innertext;
$ret['SoldBy5'] = $html->find('ul.sellerInformation img', 4)->getAttribute('alt');
$ret['Retail6'] = $html->find('span[class="price"]', 5)->innertext;
$ret['SoldBy6'] = $html->find('ul.sellerInformation img', 5)->getAttribute('alt');
$ret['Retail7'] = $html->find('span[class="price"]', 6)->innertext;
$ret['SoldBy7'] = $html->find('ul.sellerInformation img', 6)->getAttribute('alt');
Thank you for any suggestions!
I used a foreach and put the results into an array. Worked much better since the number of sellers varies by item.