Class: Garlenko::Live

Inherits:
Base
  • Object
show all
Includes:
Crawler
Defined in:
lib/garlenko/live.rb

Constant Summary collapse

LOGIN_URL =
"https://mid.live.com/si/login.aspx"
CONTACTS_URL =
"http://mpeople.live.com"

Instance Attribute Summary

Attributes inherited from Base

#password, #username

Instance Method Summary collapse

Methods included from Crawler

#agent

Methods inherited from Base

#connected?, #initialize

Constructor Details

This class inherits a constructor from Garlenko::Base

Instance Method Details

#connect!(force_connect = false) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/garlenko/live.rb', line 10

def connect!(force_connect = false)
  return @connected unless !connected? or force_connect
   = agent.get(LOGIN_URL).form('EmailPasswordForm')
  .LoginTextBox = @username
  .PasswordTextBox = @password
   = agent.submit(, .submits.first)
  @connected = !.body.include?("NotificationContainerError")
end

#contactsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/garlenko/live.rb', line 19

def contacts
  connect! unless connected?
  pool = []
  contacts_so_far = []

  on_contacts_page CONTACTS_URL do |url, page|
    pool << Thread.new(url, page) do |u, p|
      fetch_contacts_from(p)
    end
  end
  contacts_so_far = pool.each(&:join).map(&:value).flatten
  puts "fetched: #{contacts_so_far.size}"
  contacts_so_far
end