I'm trying to extract some data from HTML DIV using Simple Html Dom but it's not working right.
When I try to extract data from links/imgs it works fine but I have only a problem with DIV
s.
HTML code:
<div class="price-container">
<div class="price-calc-container" id="attributes-calc-price">
<div class="current-price-container">
7,99 EUR
</div>
</div>
</div>
I want to extarct the number inside this div
$html = file_get_html("https://www.test.de/");
$preise = $html->find('div.current-price-container');
print_r($preise);
sometime I will get an empty array sometimes nothing.
Thanks in Advance.
You have to start iterating over the find() result or use the last parameter to specify an index
$html = file_get_html("https://www.led-centrum.de/LED-Leuchtmittel/led-strahler/LED-Strahler-GU10/4058075160071.html");
$preise = $html->find('div.current-price-container', 0);
print_r($preise);
You can use a simple Jquery command like this Try this
<div class="price-container">
<div class="price-calc-container" id="attributes-calc-price">
<div class="current-price-container">
7,99 EUR
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
var x = $('.current-price-container').text();
console.log(x);
</script>