Class: SearchProviders
- Inherits:
-
Object
- Object
- SearchProviders
- Defined in:
- lib/search.rb
Class Method Summary collapse
Class Method Details
.bing(keyword) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/search.rb', line 8 def self.bing(keyword) Display.before_result res = RestClient.get 'https://bing.com/search/', params: { q: keyword } = Nokogiri::HTML.parse(res).xpath('//li[@class="b_algo"] //h2 //a') .each do |tag| Display. tag end Display.after_result end |
.gems(keyword) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/search.rb', line 18 def self.gems(keyword) Display.before_result res = RestClient.get "https://rubygems.org/search?utf8=%E2%9C%93&query=#{keyword}" = Nokogiri::HTML.parse(res).xpath('//a[@class="gems__gem"]') .each do |tag| if tag[:href].start_with?('/') tag[:href] = 'https://rubygems.org' + tag[:href] end Display. tag end Display.after_result end |
.help(_noarg = nil) ⇒ Object
44 45 46 |
# File 'lib/search.rb', line 44 def self.help(_noarg = nil) Display.help! end |
.so(keyword) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/search.rb', line 31 def self.so(keyword) Display.before_result res = RestClient.get "https://stackoverflow.com/search?q=#{keyword}" = Nokogiri::HTML.parse(res).xpath('//a[@class="question-hyperlink"]') .each do |tag| if tag[:href].start_with?('/') tag[:href] = 'https://stackoverflow.com' + tag[:href] end Display. tag end Display.after_result end |