I want to scrape a star based rating, that is the corresponding code
<div class="product_detail_info_rating_stars">
<div class="product_detail_star full"></div>
<div class="product_detail_star full"></div>
<div class="product_detail_star full"></div>
<div class="product_detail_star full"></div>
<div class="product_detail_star"></div>
</div>
Every rating has this codesnippet. I am looking for a way to convert these snippets into numbers like this one would be a 4 (4 of 5 stars).
The way that comes to my mind is to match the whole block for each rating and then match the full class and count it, but maybe there is a better way that I am not seeing.
Is there a better way to solve this problem?
Thanks!
Here is a quick example of how you can use SimpleXML parser and XPath.
For test html page like this:
It will output something like:
Play with this to adjust to your needs.