Skip to content

Instantly share code, notes, and snippets.

@laurynas
Created January 18, 2011 20:18
Show Gist options
  • Save laurynas/785058 to your computer and use it in GitHub Desktop.
Save laurynas/785058 to your computer and use it in GitHub Desktop.
Convert vodafone360 contacts html to VCF
# Convert vodafone360 contacts html to VCF
require 'rubygems'
gem 'nokogiri'
gem 'vpim'
require 'nokogiri'
require 'vpim/vcard'
Dir.glob("html/*.html").each do |file|
doc = Nokogiri.parse(File.read(file))
doc.css('#contacts-list li').each do |li|
dname = li.at('h4').text
dphone = li.at('.phone').text
vcard = Vpim::Vcard::Maker.make2 do |maker|
maker.add_name do |name|
name.given = dname
next if dphone.empty?
maker.add_tel(dphone) do |tel|
end
end
end
puts vcard.to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment