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