juust ~ php oddities

Unordered list of one element
  • rss
  • begin
  • about
    • vcard
    • WTF is BroJesus
  • php scripts
    • flickr wp widget
    • google multi key serp tool, php script
    • gwt plugin
  • php classes
    • php pagerank class
    • fibonacci class
    • robots.txt parser php class
  • serp
    • serp dashboard wordpress plugin
  • services

bing

juust | 21/08/2009

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>
Categories
php, serp
Tags
php, serp
Comments rss
Comments rss
Trackback
Trackback

« vidi 7search php trends »

One Response to “bing”

  1. sandrine says:
    15/09/2009 at 9:43 am

    Hey
    Good thank you :)

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

    Reply

Leave a Reply

Click here to cancel reply.

Recent Posts

  • Pagerank sculpting session
  • wish you were here
  • interesting : seo panel
  • availability test
  • Mayday

click me!
rss
Comments rss
Blog Directory
Web Developement Blogs - BlogCatalog Blog Directory
Listed in LS Blogs the Blog Directory and Blog Search Engine
Blog Flux Directory
joopita.com free web directory and search engine
design by jide
sitemap
17239 confirmed spam kills