Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>&lt;?php $url = 'http://www.amazon.com/gp/offer-listing/B0036RNK7O/ref=dp_olp_new?ie=UTF8&amp;qid=1319582305&amp;sr=8-2'; $dom = new DomDocument(); $content = file_get_contents($url); $dom-&gt;loadHTML($content); $results = array(); $classes_to_collect = array('price', 'shipping_block', 'condition', 'sellerInformation'); $seller_elements = array('name', 'rating', 'stock_info', 'item_info'); foreach($dom-&gt;getElementsByTagName('tbody') as $tb) { if($tb-&gt;hasAttribute('class') &amp;&amp; stripos($tb-&gt;getAttribute('class'), 'result')!==false) { foreach($tb-&gt;getElementsByTagName('tr') as $tr) { $new_result = array(); foreach($tr-&gt;getElementsByTagName('td') as $td) { foreach($td-&gt;childNodes as $cne) { foreach($classes_to_collect as $ctc) { if($cne-&gt;hasAttributes() &amp;&amp; $cne-&gt;getAttribute('class') &amp;&amp; stripos($cne-&gt;getAttribute('class'), $ctc)!==false) { if($cne-&gt;localName=='ul') { $new_sellern = array(); $lis = $cne-&gt;getElementsByTagName('li'); foreach($lis as $lii=&gt;$lie) { $value = $lie-&gt;textContent; if($seller_elements[$lii]=='item_info') { $cutoff = strpos($value, 'amznJQ.onReady'); if($cutoff) $value = substr($value, 0, $cutoff); } else if($seller_elements[$lii]=='name') { $cutoff = strpos($value, 'Seller:'); if($cutoff!==false) $value = substr($value, 7); } else if($seller_elements[$lii]=='rating') { $cutoff = strpos($value, 'Seller Rating:'); if($cutoff!==false) $value = substr($value, 14); } $new_seller[$seller_elements[$lii]] = trim($value); } $new_result[$ctc] = $new_seller; } else $new_result[$ctc] = $cne-&gt;textContent; } } } } $results[] = $new_result; } } } print_r($results); </code></pre> <p>Will print a huge multi-dimensional array</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload