Class: AddressBookImporter::Yahoo

Inherits:
Importer
  • Object
show all
Defined in:
lib/address_book_importer.rb

Instance Attribute Summary

Attributes inherited from Importer

#agent, #contacts

Instance Method Summary collapse

Methods inherited from Importer

#initialize

Constructor Details

This class inherits a constructor from AddressBookImporter::Importer

Instance Method Details

#fetch_contacts(page) ⇒ Object



123
124
125
126
# File 'lib/address_book_importer.rb', line 123

def fetch_contacts(page)
  contact_page = @agent.get("http://address.mail.yahoo.com/")
  contact_page.links.select{|l|l.text =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/}.collect{|l|l.text}.uniq
end

#login(login, password) ⇒ Object



113
114
115
116
117
118
119
120
121
# File 'lib/address_book_importer.rb', line 113

def (, password)
  page = @agent.get('https://login.yahoo.com/config/login_verify2?&.src=ym')
  form = page.forms.first
  form.fields.find {|f| f.name == 'login'}.value = 
  form.fields.find {|f| f.name == 'passwd'}.value = Iconv.iconv('latin1', 'utf-8', password)
  page = @agent.submit(form, form.buttons.first)
  raise LoginErrorException if page.body.match(/<div class="yregertxt">/)
  @agent.click(page.links.first)
end