From: "reed.adam@..." Date: 2006-08-10T07:45:15+09:00 Subject: Re: Entering data into Excel, in specific iterated rows/columns Shoot, pardon the "ef" (def) and the excel.close in there, those are mistakes. reed.adam@gmail.com wrote: > I have a script that spiders a page looking for elements. In this > specific case, I'm looking for links (innerText and href). > > I have this script working so far to output data to a text file, but > I'd like to output it to an Excel file for organization. I'm getting > stuck however trying to think of the correct method to put all of the > link.innerText values into A1, A2, A3, etc and the corresponding > link.href into B1, B2, etc. > > Here is the code I have so far (with the normal text file code in place > of the excel code I have yet to think of): > > ef grab_links(url) > $ie.goto(url) > excel = WIN32OLE.new("excel.application") > excel.visible = true > workbook = excel.workbooks.add > workbook.saveas("#{Project}_links.xls") > workbook.close > > linkfile.puts "\n#{url}" > $ie.links.each{|link| > linkfile.puts("#{link.innerText} - #{link.href}") unless > link.innerText.empty? > } > > linkfile.puts "\n\n" > end > > One big file with it formatted like this would be fine, or even a > different worksheet for each URL would be great. I'm not really > concered with that. Can you guys give me hand? > > Thanks!