-
-
Save radar/2723306 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Animals.each do |letter, results| | |
10.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