I'm trying to scrape the rating score of review sites, using Laravel 4 and the Symfony DomCrawler. Let's take this site as an example: http://estorereview.com.au/s/5951/A-Supplements I want to get the 4.8 of 5 Stars
This is partial code of my attempt:
<?php
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\CssSelector\CssSelector;
function getRatingEstoreReview($url){
$html = getHtmlCurl($url);
$crawler = new Crawler($html);
$crawler = $crawler->filter('span[itemprop="ratingValue"]');
var_dump($crawler);
die("test");
return normalize($crawler,5);
}
The var_dump returns following:
object(Symfony\Component\DomCrawler\Crawler)[280]
protected 'uri' => null
private 'defaultNamespacePrefix' => string 'default' (length=7)
private 'namespaces' =>
array (size=0)
empty
I tried this with other sites etc. but I'm always getting an empty object. Accessing the value with $crawler->first
doesn't work as well.
What am I doing wrong? Thank you.
Edit: Even if I'm filtering for "div" the Crawler remains empty. The PHP Simple HTML DOM Parser works fine