From: steven gre Date: 2012-06-29T00:35:04+09:00 Subject: Re: faster CSV writing steven gre wrote in post #1062601: > steven@steven:~/Desktop$ ruby test.rb > bname=["Firestone Complete Auto CareQuality Imports IncSunshine Auto > Sales And ServiceA & I Auto Complex IncWray's Auto Service IncForeign > Car Clinic & Parts IncFrank's Guaranteed A/C & Auto RepairJJ's Custom > Import Repair IncBill's TransmissionGordon's AutomotiveSpeedy Muffler & > Auto RepairBeach Auto CareAmerican AutoMr TransmissionE & M Motors > IncLeasure AutomotiveAll Pro AutomotiveB & S Auto SalvageGoodyear > Certified Auto & Tire CentersAction Transmission ServiceAAA > TransmissionAa AutomotiveMike Ferran IncParadise Transmission > ServiceApex TexacoGoodyear Certified Auto & Tire CenterJerry Bush Auto > RepairReilly Auto & Electric RepairAamco TransmissionsSal's TowingA & A > Auto & Truck CenterMeineke Car Care CentersACDelcoMeineke Car Care > CentersAsk an Auto Mechanic Online - Just AnswerSafelite Auto GlassTire > KingdomGoodyear Auto Service CenterCar-X Auto ServiceCottman > Transmission and Total Auto CareSears Auto CenterAAMCO Transmissions & > Auto RepairMaaco Collision Repair & Auto PaintingDaytona Converter", " > "] > phone=" 850-863-2161 904-548-0331 850-785-7229 727-937-2902 321-259-3661 > 561-684-6920 904-721-6646 850-763-1977 904-644-0446 321-267-5000 > 850-249-8416 386-428-1941 850-478-4050 772-283-4610 813-684-1553 > 904-241-4800 877-536-6254 954-755-5584 386-668-8744 305-944-0509 > 904-739-9977 904-390-0993 305-293-0923 561-746-8069 561-488-1822 > 352-378-4525 386-254-8660 321-268-2626 954-566-5155 407-982-3002" > > there should be 30 business names and 30 phone numbers.and i can't seem > to get a space at the end of each business but thats whole other thing still havn't got any help with this and tried several things anyone, here is what is on my script now #!/usr/bin/env ruby require 'rubygems' require 'sendfile' require 'fastercsv' require 'nokogiri' require 'open-uri' page = Nokogiri::HTML(open("http://www.yellowpages.com/florida/auto-repair?q=auto+repair")) #http://www.yellowpages.com/florida/auto-repair?page=2&q=auto+repair #addy = page.css("span.street-address").text #csz = page.css("span.city-state").text #count = page.css("p.result-count").text #count = count.gsub(/Results 1-30 of /,'') pho=[] page.css("span.business-phone.phone").each do |pho| phone=[] phone = pho.text bname = [] page.css("a.no-tracks.url").each do |biz| bname = biz.text FasterCSV.open("test.csv", "a") do |csv| csv << [phone] end end end -- Posted via http://www.ruby-forum.com/.