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-0.0.33.262 lib/ish/crawler.rb
ish_models-0.0.33.261 lib/ish/crawler.rb
ish_models-0.0.33.260 lib/ish/crawler.rb
ish_models-0.0.33.259 lib/ish/crawler.rb
ish_models-0.0.33.258 lib/ish/crawler.rb
ish_models-0.0.33.257 lib/ish/crawler.rb
ish_models-0.0.33.256 lib/ish/crawler.rb
ish_models-0.0.33.255 lib/ish/crawler.rb
ish_models-0.0.33.254 lib/ish/crawler.rb
ish_models-0.0.33.253 lib/ish/crawler.rb
ish_models-0.0.33.252 lib/ish/crawler.rb
ish_models-0.0.33.251 lib/ish/crawler.rb
ish_models-0.0.33.250 lib/ish/crawler.rb
ish_models-0.0.33.249 lib/ish/crawler.rb
ish_models-0.0.33.248 lib/ish/crawler.rb
ish_models-0.0.33.247 lib/ish/crawler.rb
ish_models-0.0.33.246 lib/ish/crawler.rb
ish_models-0.0.33.245 lib/ish/crawler.rb
ish_models-0.0.33.244 lib/ish/crawler.rb
ish_models-0.0.33.243 lib/ish/crawler.rb