Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattetti/ruby-web-search
A Ruby gem that provides a way to retrieve search results via the main search engines using Ruby
https://github.com/mattetti/ruby-web-search
Last synced: 3 months ago
JSON representation
A Ruby gem that provides a way to retrieve search results via the main search engines using Ruby
- Host: GitHub
- URL: https://github.com/mattetti/ruby-web-search
- Owner: mattetti
- License: mit
- Created: 2009-01-03T20:08:21.000Z (about 16 years ago)
- Default Branch: master
- Last Pushed: 2013-06-17T08:01:20.000Z (over 11 years ago)
- Last Synced: 2024-10-14T21:19:31.684Z (4 months ago)
- Language: Ruby
- Homepage:
- Size: 129 KB
- Stars: 44
- Watchers: 7
- Forks: 18
- Open Issues: 2
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
README
# Ruby Web Search
This gem allows you to query google search engine from Ruby.
So far, only Google is supported.Simple example on how to query Google:
>> require 'ruby-web-search'
=> true
>> response = RubyWebSearch::Google.search(:query => "Natalie Portman")
>> response.results
=> [{:content=>"Natalie Portman, Star Wars, Phantom Menace, Attack of the Clones, Amidala, Leon, Professional, Where The Heart Is, Anywhere But Here, Seagull, Heat, ...", :title=>"Natalie Portman . Com - News", :url=>"http://www.natalieportman.com/", :domain=>"www.natalieportman.com", :cache_url=>"http://www.google.com/search?q=cache:9hGoJVGBJ2sJ:www.natalieportman.com"}, {:content=>"Natalie Portman was born on June 9th, 1981 in Jerusalem, Israel, as the... Visit IMDb for Photos, Filmography, Discussions, Bio, News, Awards, Agent, ...", :title=>"Natalie Portman", :url=>"http://www.imdb.com/name/nm0000204/", :domain=>"www.imdb.com", :cache_url=>"http://www.google.com/search?q=cache:JLzGjsYYdlkJ:www.imdb.com"}, {:content=>"Natalie Portman (Hebrew: \327\240\327\230\327\234\327\231 \327\244\327\225\327\250\327\230\327\236\327\237\342\200\216; born Natalie Hershlag June 9, 1981) is an Israeli-American actress. Portman began her career in the early 1990s, ...", :title=>"Natalie Portman - Wikipedia, the free encyclopedia", :url=>"http://en.wikipedia.org/wiki/Natalie_Portman", :domain=>"en.wikipedia.org", :cache_url=>"http://www.google.com/search?q=cache:32A4VEkC23gJ:en.wikipedia.org"}, {:content=>"Aug 30, 2008 ... media on Miss Portman. You may recognize Natalie for her roles in .... is in in no way affiliated with Natalie Portman or her management. ...", :title=>"Natalie Portman ORG ++{natalie-p.org} | your premiere NATALIE ...", :url=>"http://www.natalie-p.org/", :domain=>"www.natalie-p.org", :cache_url=>"http://www.google.com/search?q=cache:wv-CVcMW2SEJ:www.natalie-p.org"}]
A google search returns a Response instance. Call `results` on the response to get the array on result.
A Result is a simple hash object with few keys available:* title Title of the result
* url Url of the result
* domain Root url of the result
* content Snippet of the result content
* cache\_url Google cache urlBy default, only the 4 top results get retrieved, you can specify the exact amount of results you want by passing the size argument.
RubyWebSearch::Google.search(:query => "Natalie Portman", :size => 10)## TODO
* Full support of the google api
* support more search engines (Yahoo, live etc...)## Experimentations
Here are some benchmarks, it looks like running multiple concurrent threads is often not worth it
http://gist.github.com/45350
warmed up jruby benchmarks