class SearchProviders

Public Class Methods

bing(keyword) click to toggle source
# File lib/search.rb, line 8
def self.bing(keyword)
  Display.before_result
  res =  RestClient.get 'https://bing.com/search/', params: { q: keyword }
  tags = Nokogiri::HTML.parse(res).xpath('//li[@class="b_algo"] //h2 //a')
  tags.each do |tag|
    Display.tags tag
  end
  Display.after_result
end
gems(keyword) click to toggle source
# 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}"
  tags = Nokogiri::HTML.parse(res).xpath('//a[@class="gems__gem"]')
  tags.each do |tag|
    if tag[:href].start_with?('/')
      tag[:href] = 'https://rubygems.org' + tag[:href]
    end
    Display.tags tag
  end
  Display.after_result
end
help(_noarg = nil) click to toggle source
# File lib/search.rb, line 44
def self.help(_noarg = nil)
  Display.help!
end
so(keyword) click to toggle source
# File lib/search.rb, line 31
def self.so(keyword)
  Display.before_result
  res = RestClient.get "https://stackoverflow.com/search?q=#{keyword}"
  tags = Nokogiri::HTML.parse(res).xpath('//a[@class="question-hyperlink"]')
  tags.each do |tag|
    if tag[:href].start_with?('/')
      tag[:href] = 'https://stackoverflow.com' + tag[:href]
    end
    Display.tags tag
  end
  Display.after_result
end