bing

for completeness : php bing serp scraping :

  1. $query = 'serp';
  2. $page = 1;
  3. $start = ($page-1)*10;
  4. $url = 'http://www.bing.com/search?q='.urlencode($query)."&first=".($start+1);
  5.  
  6. $curl_handle = curl_init();
  7. curl_setopt($curl_handle,CURLOPT_URL, $url);
  8. curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
  9. curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
  10. $return = curl_exec($curl_handle);
  11. curl_close($curl_handle);
  12.  
  13. $parts = split('<h3>', $return);
  14.  
  15. for($j=1;$j<count ($parts);$j++)
  16. {
  17.     $p=$parts[$j];
  18.     preg_match('#<a\s+.*?href=[\'"]([^\'"]+)[\'"]\s*(?:title=[\'"]([^\'"]+)[\'"])?.*?>((?:(?!).)*)#i', $p, $urls);
  19.     echo "position: ".($start +$j)." url: ".$urls[1]." title: ".$urls[3].'<br />';
  20. }
  21. </count></h3>
Posted in php, serp and tagged , .

One Comment

  1. Hey
    Good thank you :)

    You can add this variable in the url : &count=200
    I think the max is 200

Leave a Reply

Your email address will not be published. Required fields are marked *