Skip to content

Instantly share code, notes, and snippets.

Created May 17, 2012 05:17
Show Gist options
  • Save anonymous/2716615 to your computer and use it in GitHub Desktop.
Save anonymous/2716615 to your computer and use it in GitHub Desktop.
animals.each do |letter, results|
total_pages.times do
doc = Nokogiri::HTML(open("http://www.ocar.org/page.php?tut=realtor-affiliate-search-results&tid=802&pid=8&first_or_last_name=#{letter}&city=&office=&btc=&op=find_a_realtor&ftut=find-a-realtor&start=#{results_per_page}"))
realtors = {}
('a'..'z').each do |n|
realtors[n] = Realtor.create
end
doc.css('div.search_results_item').each do |number|
phone_number = /\(\d{3}\)\s\d{3}-\d{4}/.match("#{number.content}")
('a'..'z').each do |n|
realtors[n].update_attributes(:phone => phone_number[0])
end
end
doc.css('div.search_results_item strong').each do |search|
('a'..'z').each do |n|
realtors[n].update_attributes(:name => search.content)
end
end
doc.css('div.search_results_item span.sresults_econtacts a:first').each do |contact|
('a'..'z').each do |n|
realtors[n].update_attributes(:email => contact.text)
end
end
results_per_page += 25
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment