From: newyorkdolluk Date: 2006-08-10T17:25:06+09:00 Subject: Re: irb output Thats great thanks. Can this be modified so that we pull out only the index names (first column of output - looks like an integer) for those lines that have the text 'example' say in them? Patrick Spence wrote: > newyorkdolluk wrote: > > hi, > > > > i have a ruby/watir script that i evoke from irb containing the > > following lines: > > > > ie_attach = Watir::IE.attach(:url, /text/) > > ie_attach.show_links > > > > this will attach to an open browser containing a webpage with 'text' in > > the url and then display all the html objects in that page. > > > > can anyone advise on how i can redirect this output in the irb window > > into a file > > > > thanks. > > require 'watir' > include Watir > > ie = IE.attach(:url, "http://www.ruby-forum.com/topic/76597#new") > file = File.new("links.txt","w+") > > ie.links.each {|link| > file.puts("#{link.innerText} - #{link.href}") unless > link.innerText.empty? > } > > file.close() > > > Portion of output (some word wrapping may occur) > ----------------- > Ruby - http://www.ruby-forum.com/forum/4 > Forum List - http://www.ruby-forum.com/ > New Topic - http://www.ruby-forum.com/topic/new?forum_id=4 > Search - http://www.ruby-forum.com/search > User settings - http://www.ruby-forum.com/user/edit > User List - http://www.ruby-forum.com/user/list > Log Out [pkspence] - http://www.ruby-forum.com/user/logout > irb output - http://www.ruby-forum.com/topic/76597#120103 > Reply with quote - > http://www.ruby-forum.com/topic/76597?reply_to=120103#postform > Enable email notification - > http://www.ruby-forum.com/topic/subscribe/76597 > > > -- > Posted via http://www.ruby-forum.com/.