I'm trying to grab all the bolded terms from a google results page and put them into an associative array, but the results are eratic. It seems to only extract single word terms and sometimes (depending on the query) it grabs words that are not bolded. Does anyone know what I'm doing wrong? Thanks in advance.
$gurl = "http://www.google.com/search?q=marketingpro";
$data = file_get_contents($gurl);
// get bolded
preg_match_all('/<b>(\w+)<\/b>/', $data, $res, PREG_PATTERN_ORDER);
$H = $res[0];
foreach($H as $X){
$bold = strtolower($X);
$array[$bold] += 1;
}
print_r($array);