I try to scrape some keywords but i get this error . I can't figure it out i think the problem is with Dom when i load from Curl. I try different methods hope you can help me with this.
With just Dom it works but i need to use with curl .
include("simple_html_dom.php");
$lines = file('key.txt', FILE_SKIP_EMPTY_LINES);
foreach ($lines as $key)
{
$bla= ucwords($key);
$in = str_replace(' ','+',$bla);
$ch = curl_init();
$url = 'http://www.google.com/search?hl=en&tbo=d&site=&source=hp&q='.$in.'&oq='.$in.'&num=20';
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$html = curl_exec($ch);
curl_close($ch);
$dom = new simple_html_dom();
$html = str_get_html($html);
@$dom->load($html);
$i=0;
$linkObjs = $html->find('h3.r a');
$content = array();
foreach ($linkObjs as $linkObj)
{
$title = trim($linkObj->plaintext);
$descr = $html->find('span.st',$i);
$i++;
$content[] = strip_tags($title.$descr);
}
var_dump($content);
}