php - Call to a member function find() on a non-object in -


i try scrape keywords error . can't figure out think problem dom when load curl. try different methods hope can me this.

with dom works need use curl .

include("simple_html_dom.php");  $lines = file('key.txt', file_skip_empty_lines);  foreach ($lines $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 $linkobj)      {         $title = trim($linkobj->plaintext);         $descr = $html->find('span.st',$i);         $i++;            $content[] = strip_tags($title.$descr);     }      var_dump($content); } 


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -