Thursday, July 26, 2012

Scraping mobile phone number from web


web.search("td").each do |e|
e = e.inner_html
if e.length > 10
tmp = e.gsub(/(\r|\n|\t|\D)/, "")

tmp.split(/(010|012|013|016|014|017|018|019)/).each do |s|
if s =~ /(010|012|013|016|014|017|018|019)/
pos = tmp =~ /#{s}/
#puts pos
if pos
number = "#{s}#{tmp[pos+3..pos+9]}"
puts number
Contact.create(:group_id => 1, :phone => number) if number.length == 10
end
end
end

end
end

1 comment:

  1. Yet another connected windows 7 ultimate activation key handicap of Home windows eight tablets is measurement. Led from the first Amazon Kindle Fireplace and followed because of the Samsung Galaxy windows anytime upgrade key Tab, Google Nexus and iPad Mini

    ReplyDelete