Cannot get html attribute using PHP Simple Html DOM

I am tryng to get the ,sold" info from eBay listing- Box with Tail Pipe Back Silencer Citroen C2 C3 C3 Pluriel GCN499 1.60875 CN499 5056107203856 | eBay. Here is the screenshot: enter image description here

As you can see I want to get ,1 sold" text on the upper right corner of the screen. I am using the class ,vi-txt-underline" to get it, however it is not working. Has anyone knows how this can be done, using other attribute or other way?. Here is the code:

            $sold = $html->find("#vi-text-unSderline", 0);

            if($sold != null){
                $item['sold'] = $sold->find("a", 0)->plaintext;
            }else{
                $item['sold'] = '';
           I am using an array $item[] because I am also searching  for more info before this part of the code.

php

Several things.

1.) You have a typo in your selector *class (ie: “#vi-text-unSderline”)
2.) It should be a class ‘.’ and not an ‘#’ in your selector value (ie: “.vi-text-underline”)

I’m not sure why its not working in your approach (after those fixes)… perhaps because when using a class to search? there is no second parameter? (as it already collects all matches?)

This seems to work:

include('../simplehtmldom/simple_html_dom.php');

$html = file_get_html('http://www.ebay.co.uk/itm/Box-With-Tail-Pipe-Rear-Back-Silencer-Fits-Citroen-C2-C3-I-C3-Pluriel-GCN499/254292997729');


$targetLink1 = $html->find('.vi-txt-underline')[0];
echo $targetLink1;

echo '<br><strong>-OR-</strong><br>';

$targetLink2 = $html->find('.vi-txt-underline');
echo $targetLink2[0];
Sponsor our Newsletter | Privacy Policy | Terms of Service