Class: Naymz
- Inherits:
-
Object
- Object
- Naymz
- Includes:
- Searchy
- Defined in:
- lib/esearchy/SocialNetworks/naymz.rb
Instance Attribute Summary collapse
-
#company_name ⇒ Object
Returns the value of attribute company_name.
-
#emails ⇒ Object
Returns the value of attribute emails.
-
#people ⇒ Object
Returns the value of attribute people.
Instance Method Summary collapse
- #enquire_person(profile) ⇒ Object
-
#initialize(maxhits = 0, start = 0) ⇒ Naymz
constructor
A new instance of Naymz.
- #parse(html) ⇒ Object
- #search(query) ⇒ Object
- #search_person(name, last) ⇒ Object
Methods included from Searchy
#clean, #fix, #hash_url, #maxhits=, #print_emails, #search_depth, #search_docs, #search_emails, #search_office_xml, #search_pdfs, #search_txts
Constructor Details
#initialize(maxhits = 0, start = 0) ⇒ Naymz
Returns a new instance of Naymz.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/esearchy/SocialNetworks/naymz.rb', line 9 def initialize(maxhits = 0, start = 0) @start = start @totalhits = maxhits @emails = [] @people = [] @company_name = nil @r_urls = Queue.new @r_docs = Queue.new @r_pdfs = Queue.new @r_txts = Queue.new @r_officexs = Queue.new @lock = Mutex.new @threads = [] end |
Instance Attribute Details
#company_name ⇒ Object
Returns the value of attribute company_name.
23 24 25 |
# File 'lib/esearchy/SocialNetworks/naymz.rb', line 23 def company_name @company_name end |
#emails ⇒ Object
Returns the value of attribute emails.
23 24 25 |
# File 'lib/esearchy/SocialNetworks/naymz.rb', line 23 def emails @emails end |
#people ⇒ Object
Returns the value of attribute people.
23 24 25 |
# File 'lib/esearchy/SocialNetworks/naymz.rb', line 23 def people @people end |
Instance Method Details
#enquire_person(profile) ⇒ Object
74 75 76 |
# File 'lib/esearchy/SocialNetworks/naymz.rb', line 74 def enquire_person(profile) # TO DO: parse profile to obtain more information end |
#parse(html) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/esearchy/SocialNetworks/naymz.rb', line 78 def parse(html) @totalhits= html.scan(/<\/b> of[ about | ]\ <b>(.*)<\/b> from/)[0][0].gsub(",","").to_i if @totalhits == 0 html.scan(/<h2 class=r><a href="([0-9A-Z\ a-z:\\\/?&=@+%.;"'()_-]+)" class=l>([\w\s]*) -/).each do |profile| @domain = @query.match(/@/) ? @query : ("@" + @query) person = profile[1].split(" ").delete_if do |x| x =~ /mr.|mr|ms.|ms|phd.|dr.|dr|phd|phd./i end name,last = person.size > 2 ? [person[0],person[-1]] : person @people << person @emails << "#{name.split(' ')[0]}.#{last.split(' ')[0]}#{@domain}" @emails << "#{name[0,1]}#{last.split(' ')[0]}#{@domain}" #@emails.concat(fix(search_person(name,last))) @emails.uniq! print_emails(@emails) end end |
#search(query) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/esearchy/SocialNetworks/naymz.rb', line 25 def search(query) @query = query http = Net::HTTP.new("www.google.com",80) begin http.start do |http| request = Net::HTTP::Get.new( "/cse?q=site:naymz.com%20%2B%20%22@%20" + CGI.escape(@company_name) + "%22&hl=en&cof=&num=100&filter=0" + "&safe=off&start=#{@start}", {'User-Agent' => UserAgent::fetch}) response = http.request(request) case response when Net::HTTPSuccess, Net::HTTPRedirection parse(response.body) @start = @start + 100 if @totalhits > @start ESearchy::LOG.puts "Searching #{self.class} from #{@start-100} to #{@start}" parse(response.body) search_emails(response.body.gsub(/<em>|<\/em>/,"")) sleep(ESearchy::DELAY) search(query) else ESearchy::LOG.puts "Searching #{self.class} from #{@start-100} to #{@start}" parse(response.body) search_emails(response.body.gsub(/<em>|<\/em>/,"")) end else return response.error! end end rescue Net::HTTPFatalError ESearchy::LOG.puts "Error: Something went wrong with the HTTP request" end @start = 0 end |
#search_person(name, last) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/esearchy/SocialNetworks/naymz.rb', line 61 def search_person(name,last) email = [] # Search Yahoo y = Yahoo.new(50) y.search("first:\"#{name}\" last:\"#{last}\"") emails.concat(y.emails).uniq! # Search Google #g = Google.new(50) #g.search("#{name} #{last}") #emails.concat(g.emails).uniq! return emails end |