Class: Garlenko::Live
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
login_form = agent.get(LOGIN_URL).form('EmailPasswordForm')
login_form.LoginTextBox = @username
login_form.PasswordTextBox = @password
login_res = agent.submit(login_form, login_form.submits.first)
@connected = !login_res.body.include?("NotificationContainerError")
end
|
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
|