# :title: Verizon backup assistant parser # Author:: Casey Link # Version:: 2008.10.22 v0 # # This script parses the "Print Contacts" html file saved from http://www.verizonwireless.com/backupassistant # into a GMail formatted CSV. It is useful for importing contacts from your verizon account to GMail. # Note: It only grabs the following information # Name, Email, Home Phone, Mobile Phone, Work Phone # # Usage:: vzwparser.rb verizon_contacts.html > contacts.csv # # Depends: hpricot # # License:: GPL v2 require 'rubygems' require 'hpricot' if ARGV.size != 1 puts "USAGE: #{__FILE__} " exit end puts "Name,E-mail,Notes,Section 1 - Description,Section 1 - Email,Section 1 - IM,Section 1 - Phone,Section 1 - Mobile,Section 1 - Pager,Section 1 - Fax,Section 1 - Company,Section 1 - Title,Section 1 - Other,Section 1 - Address,Section 2 - Description,Section 2 - Email,Section 2 - IM,Section 2 - Phone,Section 2 - Mobile,Section 2 - Pager,Section 2 - Fax,Section 2 - Company,Section 2 - Title,Section 2 - Other,Section 2 - Address" doc = open(ARGV[0]) { |f| Hpricot(f) } (doc/"html/body/div/div/div/div/div[2]/div/div[2]/table/tbody/tr").each do |row| name = (row/"td/span[@class='name more']").inner_html mobile = row.search("//td/span[@class='mobile']").inner_html[/.*<\/strong>(.*)/,1] work = row.search("//td/span[@class='work']").inner_html[/.*<\/strong>(.*)/,1] home = row.search("//td/span[@class='home']").inner_html[/.*<\/strong>(.*)/,1] email = row.search("//td/span[@class='email']/a").inner_html address = "" puts "#{name},#{email},,Personal,,,#{home},#{mobile},,,,,,#{address},Work,,,#{work},,,,,,," if name != nil and mobile != nil end