Created
January 18, 2011 20:18
-
-
Save laurynas/785058 to your computer and use it in GitHub Desktop.
Convert vodafone360 contacts html to VCF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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