Module: IRC::WWW
- Defined in:
- lib/irc-qik-bot/utils/irc-www.rb
Class Method Summary collapse
- .google(search_terms, item_count = 1) ⇒ Object
- .http_requester(httpurl, node, attribs = nil) ⇒ Object
- .unshort(short_url) ⇒ Object
- .whois(short_url) ⇒ Object
Class Method Details
.google(search_terms, item_count = 1) ⇒ Object
12 13 14 |
# File 'lib/irc-qik-bot/utils/irc-www.rb', line 12 def self.google(search_terms, item_count = 1) http_requester("http://www.google.com/search?q=#{search_terms.split.join("+")}", "div.div.cite").first.split("<").collect{|y| y.split(">")}.collect{|z| z[1]}.join end |
.http_requester(httpurl, node, attribs = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/irc-qik-bot/utils/irc-www.rb', line 24 def self.http_requester(httpurl, node, attribs=nil) begin uri = URI.parse(httpurl) http = Net::HTTP.new(uri.host, uri.port) case httpurl[5] #checking if https is there when ?s then http.use_ssl = true else http.use_ssl = false end #http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl request = Net::HTTP::Get.new(uri.request_uri) response = http.request(request) rescue response = nil end XMLMotor.get_node_from_content response.body, node, attribs end |
.unshort(short_url) ⇒ Object
16 17 18 |
# File 'lib/irc-qik-bot/utils/irc-www.rb', line 16 def self.unshort(short_url) http_requester("http://webhoudini.appspot.com/unshort_url?url=#{short_url}", "h3.a").join end |
.whois(short_url) ⇒ Object
20 21 22 |
# File 'lib/irc-qik-bot/utils/irc-www.rb', line 20 def self.whois(short_url) http_requester("http://whois.domaintools.com/#{short_url}", "div", "class='whois_record'").join end |