Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails site search with Bing API example?

Previously these folks promised a release of their implementation of Bing search for their site at the following article: http://www.globalnerdy.com/2009/06/29/learnhub-powered-by-rails-searches-with-bing/

Is anyone familiar with a Ruby or Rails lib that would facilitate site search with Bing? Google just hasn't been a good match so far with their site search and a search with MS Bing, surprisingly, seems to be a much better solution.

Otherwise, an example of how to accomplish this, even without a lib and directly using the API, would be much appreciated.

like image 885
ylluminate Avatar asked Nov 27 '25 15:11

ylluminate


1 Answers

While not a custom site search per se, you should be able to use RBing for accessing Bings search API. There's an introductory tutorial over at http://9astronauts.com/code/ruby/rbing/

To make it work like a site search, simply append a site:example.com to your queries and it will only return results from that domain. For example:

bing = RBing.new("YOURAPPID")
query = "something interesting"
results = bing.web("#{query} site:stackoverflow.com")
puts results.web.results[0].title
=> "javascript - How to illuminate a browser window/tab when something ..."
like image 139
Jakob S Avatar answered Nov 29 '25 05:11

Jakob S



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!