AddressBookImporter 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/address_book_importer.rb +16 -29
  2. metadata +3 -3
@@ -4,7 +4,7 @@ require 'cgi'
4
4
  require 'iconv'
5
5
 
6
6
  module AddressBookImporter
7
- VERSION = '0.0.12'
7
+ VERSION = '0.0.13'
8
8
 
9
9
  class EmptyEmailException < Exception ; end
10
10
  class LoginErrorException < Exception ; end
@@ -47,42 +47,29 @@ module AddressBookImporter
47
47
  raise LoginErrorException if page.body.match(/icon_err\.gif/)
48
48
  url = page.root.at('script').inner_html.match(%r{(http:[^"]+)})[0]
49
49
  p = @agent.get(url) # http://by132w.bay132.mail.live.com/mail/mail.aspx
50
- if (match = p.body.match(/(http:\/\/[^"'\/\\]*\.mail\.live\.com)/))
51
- @mode = :live
52
- else
53
- @mode = :normal
54
- end
55
50
  p
56
51
  end
57
52
 
58
53
  def fetch_contacts(page)
59
54
  rval = []
60
- if @mode == :normal
61
- params = page.body.match(/(curmbox=[^&]+)/)[1]
62
- start = page.body.match(/(a=[^"]+)/)[1]
63
- contact_page = @agent.get("/cgi-bin/AddressPicker?" + start+params + "&Context=InsertAddress&_HMaction=Edit&qF=to")
64
- rval = get_email(contact_page.body)
55
+ link = page.links.select{|l|l.href.match(/Inbox/)}.first
56
+ p = @agent.click(link)
57
+ link = page.links.select{|l|l.href.match(/EditMessage/)}.first
58
+ if p.body.match(/NewMessageGo/)
59
+ if (match = p.body.match(/(\/mail\/ApplicationMainReach\.aspx\?Control=EditMessage[^"]+)/))
60
+ p = @agent.get(match[1])
61
+ end
62
+ form = p.forms.first
63
+ form.add_field!('ToContact.x', 9)
64
+ form.add_field!('ToContact.y', 11)
65
+ p2 = form.submit
66
+ rval = get_email(p2.body)
65
67
  else
66
- link = page.links.select{|l|l.href.match(/Inbox/)}.first
67
68
  p = @agent.click(link)
68
- link = page.links.select{|l|l.href.match(/EditMessage/)}.first
69
- if p.body.match(/NewMessageGo/)
70
- if (match = p.body.match(/(\/mail\/ApplicationMainReach\.aspx\?Control=EditMessage[^"]+)/))
71
- p = @agent.get(match[1])
72
- end
73
- form = p.forms.first
74
- form.add_field!('ToContact.x', 9)
75
- form.add_field!('ToContact.y', 11)
76
- p2 = form.submit
77
- rval = get_email(p2.body)
78
- else
79
- p = @agent.click(link)
80
- rval = get_email(p.body, /([_\-a-z0-9.A-Z]+(%|\\x)40((?:[-a-z0-9]+\.)+[a-z]{2,}))/)
81
- rval.collect!{|a|a.gsub(/(%40|\\x40)/, '@')}
82
- end
83
-
84
- rval.reject{|a|a == @login_email}
69
+ rval = get_email(p.body, /([_\-a-z0-9.A-Z]+(%|\\x)40((?:[-a-z0-9]+\.)+[a-z]{2,}))/)
70
+ rval.collect!{|a|a.gsub(/(%40|\\x40)/, '@')}
85
71
  end
72
+ rval.reject{|a|a == @login_email}
86
73
  end
87
74
 
88
75
  protected
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: AddressBookImporter
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.12
7
- date: 2007-09-27 00:00:00 +02:00
6
+ version: 0.0.13
7
+ date: 2007-11-20 00:00:00 +01:00
8
8
  summary: Mechanize scraper for address books
9
9
  require_paths:
10
10
  - lib