Sha256: 731bd0c048af0cf0672c06095ebe830a9fd78b12220fb70bdbb7cc91e44d579c

Contents?: true

Size: 734 Bytes

Versions: 190

Compression:

Stored size: 734 Bytes

Contents

module Ish
  class Crawler

    def self.google_first_result text
      result = HTTParty.get( "https://www.google.com/search?q=#{text}", :verify => false )
      r = Nokogiri::HTML(result.body)
      website = r.css('cite')[0].text
      website = "https://#{website}" unless website[0..3] == 'http'

      begin
        r = HTTParty.get( website, :verify => false )
      rescue OpenSSL::SSL::SSLError => e
        return { :url => website }
      end

      return { :url => website, :html => r.body }
    end

    def self.look_for_emails text
      email_regex = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i
      result = text.scan( email_regex )
      return result.length > 0 ? result.join(',') : nil
    end

  end
end

Version data entries

190 entries across 190 versions & 1 rubygems

Version Path
ish_models-3.0.0.1 lib/ish/crawler.rb
ish_models-0.0.33.304 lib/ish/crawler.rb
ish_models-0.0.33.303 lib/ish/crawler.rb
ish_models-0.0.33.302 lib/ish/crawler.rb
ish_models-0.0.33.301 lib/ish/crawler.rb
ish_models-0.0.33.300 lib/ish/crawler.rb
ish_models-0.0.33.299 lib/ish/crawler.rb
ish_models-0.0.33.298 lib/ish/crawler.rb
ish_models-0.0.33.297 lib/ish/crawler.rb
ish_models-0.0.33.296 lib/ish/crawler.rb
ish_models-0.0.33.295 lib/ish/crawler.rb
ish_models-0.0.33.294 lib/ish/crawler.rb
ish_models-0.0.33.293 lib/ish/crawler.rb
ish_models-0.0.33.292 lib/ish/crawler.rb
ish_models-0.0.33.291 lib/ish/crawler.rb
ish_models-0.0.33.287 lib/ish/crawler.rb
ish_models-0.0.33.286 lib/ish/crawler.rb
ish_models-0.0.33.285 lib/ish/crawler.rb
ish_models-0.0.33.284 lib/ish/crawler.rb
ish_models-0.0.33.283 lib/ish/crawler.rb