yanwong / ganon

Automatically exported from code.google.com/p/ganon
0 stars 0 forks source link

problems getting text from SPAN #13

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The following code echos nothing.  It should echo some prices.

$html = file_get_dom('http://www.libertysilver.se/kopa/guldtackor');
foreach($html->select('div.productBox') as $product){
   echo $product->select('span.productUnitSellPrice span', 0)->getPlainText() . "<br>";
}

It seems like whenever I have a problem with ganon, it's related to SPAN tags.

I'm using the latest version of ganon.

Thanks for you help :)

Original issue reported on code.google.com by hobblek...@gmail.com on 17 Jun 2012 at 3:40

GoogleCodeExporter commented 8 years ago
This looks like expected behaviour. If you look at the source of the website, 
you'll see that the website seems to obfuscate its prices using JavaScript. 
This works:

echo '<script 
src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" 
type="text/javascript"></script>';

$html = file_get_dom('http://www.libertysilver.se/kopa/guldtackor');
foreach($html->select('div.productBox') as $product){
   echo $product->select('span.productUnitSellPrice', 0)->html() . "<br>\n";
}

Original comment by niels....@gmail.com on 18 Jun 2012 at 1:44

GoogleCodeExporter commented 8 years ago
Thank you very much!

Original comment by hobblek...@gmail.com on 20 Jun 2012 at 7:06