[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

irb output

newyorkdolluk

8/9/2006 3:33:00 PM

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.

7 Answers

Patrick Spence

8/9/2006 5:12:00 PM

0

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-...topic/76597...)
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.c...
Forum List - http://www.ruby-...
New Topic - http://www.ruby-...topic/new?forum_id=4
Search - http://www.ruby-...search
User settings - http://www.ruby-...user/edit
User List - http://www.ruby-...user/list
Log Out [pkspence] - http://www.ruby-...user/logout
irb output - http://www.ruby-...topic/76597#120103
Reply with quote -
http://www.ruby-...topic/76597?reply_to=120103#postform
Enable email notification -
http://www.ruby-...topic/subscribe/76597


--
Posted via http://www.ruby-....

newyorkdolluk

8/10/2006 8:22:00 AM

0

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-...topic/76597...)
> 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.c...
> Forum List - http://www.ruby-...
> New Topic - http://www.ruby-...topic/new?forum_id=4
> Search - http://www.ruby-...search
> User settings - http://www.ruby-...user/edit
> User List - http://www.ruby-...user/list
> Log Out [pkspence] - http://www.ruby-...user/logout
> irb output - http://www.ruby-...topic/76597#120103
> Reply with quote -
> http://www.ruby-...topic/76597?reply_to=120103#postform
> Enable email notification -
> http://www.ruby-...topic/subscribe/76597
>
>
> --
> Posted via http://www.ruby-....

Nicky

4/25/2009 9:19:00 AM

0

On Apr 24, 12:21 am, Aqua <a...@internode.on.net> wrote:
> Nicky wrote:
> > On Apr 23, 4:02 pm, Tim S <T...@timsilverman.demon.co.uk> wrote:
> >> Nicky wrote:
> >>> self grandisation (sp?)
> >> Maybe self aggrandisation?
>
> >> Tim
>
> > Yep! thanks! Having a thick day, mind, it was early by my standards.
> > It is probably just as well that I have done no work today other than
> > changing the name of something and then changing it back.
> > Ah maybe I should ask for help for that too.
> > I have some robots, cyborg things that are broadly people shaped I
> > called them 'pseuds' then, as they were used as combat troops/heavies,
> > I called them 'henchborgs' and hated that more. I'm not happy with
> > either word. It's near future SF and I am hoping for an adult audience
> > ( shrug) actually any audience might be good.
> > Any suggestions?
>
> I'm reminded of BSG and the humans' offensive nickname for the cylons
> (both humaniform and metallic): 'toasters'.  I think it needs to be
> short and snappy to work.  I'm thinking 'tanks', 'bricks', 'bullets'.
>
> Aqua- Hide quoted text -
>
> - Show quoted text -

Good ideas. I probably need to get writing.

Jacey Bedford

4/25/2009 12:43:00 PM

0

In message
<b3242fc2-795b-4e8b-a5a3-cc20cbeac002@h28g2000yqd.googlegroups.com>,
Nicky <nicky.matthews@btinternet.com> writes
>On Apr 24, 12:21 am, Aqua <a...@internode.on.net> wrote:
>> Nicky wrote:
>> > On Apr 23, 4:02 pm, Tim S <T...@timsilverman.demon.co.uk> wrote:
>> >> Nicky wrote:
>> >>> self grandisation (sp?)
>> >> Maybe self aggrandisation?
>>
>> >> Tim
>>
>> > Yep! thanks! Having a thick day, mind, it was early by my standards.
>> > It is probably just as well that I have done no work today other than
>> > changing the name of something and then changing it back.
>> > Ah maybe I should ask for help for that too.
>> > I have some robots, cyborg things that are broadly people shaped I
>> > called them 'pseuds' then, as they were used as combat troops/heavies,
>> > I called them 'henchborgs' and hated that more. I'm not happy with
>> > either word. It's near future SF and I am hoping for an adult audience
>> > ( shrug) actually any audience might be good.
>> > Any suggestions?
>>
>> I'm reminded of BSG and the humans' offensive nickname for the cylons
>> (both humaniform and metallic): 'toasters'.  I think it needs to be
>> short and snappy to work.  I'm thinking 'tanks', 'bricks', 'bullets'.
>>
>> Aqua- Hide quoted text -
>>
>> - Show quoted text -
>
>Good ideas. I probably need to get writing.

Actually if it's near future SF and the culture is derived from ours
(rather than an alternative Earth) what's the problem with calling them
'borgs' because the Star Trek reference could well be deliberate on
behalf of the people who made them.

I have a friend who refers to her new bosses as 'the Borg' because her
company was taken over and assimilated.

Jacey

--
Jacey Bedford
jacey at artisan hyphen harmony dot com
posting via usenet and not googlegroups, ourdebate
or any other forum that reprints usenet posts as
though they were the forum's own

Bill Swears

4/25/2009 7:05:00 PM

0

Jacey Bedford wrote:
> Actually if it's near future SF and the culture is derived from ours
> (rather than an alternative Earth) what's the problem with calling them
> 'borgs' because the Star Trek reference could well be deliberate on
> behalf of the people who made them.
>
> I have a friend who refers to her new bosses as 'the Borg' because her
> company was taken over and assimilated.
>
> Jacey
>
Pop culture references can work very well, but some editors just seem to
hate them. My main character from Seraglio liked Kris Kristopherson
songs. I had several people tell me they dated the character and
weren't topical enough. Making Jake a Green Day fan wouldn't have
helped, and it was the wrong tone for his situation.

I'd use "the Borg" in a heartbeat if the situation was right. I think
most readers would recognize the referent, even if they weren't SF fans.

Bill

--
Living on the polemic may be temporarily satisfying, but it will raise
your blood-pressure, and gives you tunnel vision.

spam

4/25/2009 11:42:00 PM

0

On Sat, 25 Apr 2009 09:42:19 -0400, mbottorff@lshelby.com (Michelle
Bottorff) wrote:

>Jonathan L Cunningham <spam@sofluc.co.uk.invalid> wrote:

>> If I haven't accidentally offended beyond tolerance, and you are
>> actually reading this...

>...Just for the record, you wouldn't be on my twit list if I had one.
>You aren't nearly good enough at offending people by accident to succeed
>at offending me. If you want to earn one of my snarky set-downs, you
>are going to have to try *much* harder.

Oh, good.

I don't need snarky set-downs at the moment. (More precisely, I don't
want any. I should leave it to others whether I need them.)

>> Which ones did you decide to rewrite? I'd be quite interested in seeing
>> the revised versions, particularly in the light of other people's
>> reactions to them.
>
>I rewrote Talking With Winds (Prince Asond), and Cantata (ex-sailor at
>court). I added one for Harp and Gyre.
>
>I think looking at the changes would be a great idea if the deadline
>wasn't past. But I find this whole submitting stuff hard enough on me
>emotionally as is -- having someone pointing out flaws in something I
>have already submitted is something I would find extremely painful.

I can accept that. If I'd just sent something off, having people point
out even typos would be painful. :-)

Good luck with your entries.

Jonathan

--
"If common sense were a reliable guide, we wouldn't need
science in the first place." Amanda Gefter, New Scientist.

John

4/27/2009 8:27:00 AM

0

goldfarb@ocf.berkeley.edu (David Goldfarb) wrote:

>In article <0jp6v4l7r7vmcel4ou64reni88jlhm1cop@4ax.com>,
>nobody <no@spam.please> wrote:
>>"You will be assimilated, resistance is vital!" -- the Grob
>
>So we should resist the dominance of established chess opening
>theory and always open 1. g4?

We should maybe recognize when we are playing games.

--
FAQ POINTER: http://www.lshelby.com/ras...
my fiction: http://fictionfromnobody.bl...