[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

downloading web pages in watir

michael

8/8/2006 7:30:00 PM

could anybody tell me how to download web pages accessed through
watir??

thanks

michael

4 Answers

Brian Cowdery

8/8/2006 10:37:00 PM

0

michael wrote:
> could anybody tell me how to download web pages accessed through
> watir??
>
> thanks
>
> michael

While there isn't any methods in Watir to directly download a webpage to
a file, you can get the HTML content yourself and do your own file
writing.

for example;

ie = Watir::IE.new
ie.goto('www.google.ca')

File.open('google.html', "wb") { |f|
f << '<html>'
f << ie.html
f << '</html>'
}

Note that the Watir.ie.html method returns the document.body, which does
not include the opening and closing <html> tags - so you'll need to
include them in the file writing block.

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

michael

8/8/2006 11:22:00 PM

0

thanks..


body is all I want..

okay.. let's suppose i would like to download 'www.yahoo.com', and save
it as c:\yahoo\yahoo.htm

would you show me how I can realize this in ruby, watir??

thank you so much..


michael

Brian Cowdery wrote:
> michael wrote:
> > could anybody tell me how to download web pages accessed through
> > watir??
> >
> > thanks
> >
> > michael
>
> While there isn't any methods in Watir to directly download a webpage to
> a file, you can get the HTML content yourself and do your own file
> writing.
>
> for example;
>
> ie = Watir::IE.new
> ie.goto('www.google.ca')
>
> File.open('google.html', "wb") { |f|
> f << '<html>'
> f << ie.html
> f << '</html>'
> }
>
> Note that the Watir.ie.html method returns the document.body, which does
> not include the opening and closing <html> tags - so you'll need to
> include them in the file writing block.
>
> --
> Posted via http://www.ruby-....

Chris McMahon

8/8/2006 11:35:00 PM

0


> Note that the Watir.ie.html method returns the document.body, which does
> not include the opening and closing <html> tags - so you'll need to
> include them in the file writing block.

Also note that Watir does *not* return the actual HTML. It returns the
DOM, represented as HTML. As an example, HTML generated from Watir's
"ie.html:" always has closed <p> tags, but the page itself might not.
This causes trouble sometimes.

Tim McGaughy

1/20/2009 1:20:00 AM

0

Matt Silberstein wrote:
> On Mon, 19 Jan 2009 07:56:56 -0600, in alt.atheism , Tim McGaughy
> <teekem@toast.net> in
> <Z7ednaSnlp81G-nUnZ2dnUVZ_rLinZ2d@posted.toastnet> wrote:
>
>> Matt Silberstein wrote:
>>> On Sun, 18 Jan 2009 00:09:29 -0600, in alt.atheism , Tim McGaughy
>>> <teekem@toast.net> in
>>> <6NqdnXZyHqMHWu_UnZ2dnUVZ_g0AAAAA@posted.toastnet> wrote:
>>>
>>>> Matt Silberstein wrote:
>>>>> On Wed, 14 Jan 2009 21:24:41 -0800, in alt.atheism , Jack
>>>>> <jack@the_wild_kingdom.com> in
>>>>> <pMzbl.14293$c45.14142@nlpi065.nbdc.sbc.com> wrote:
>>>>>
>>>>>> Ben Kaufman wrote:
>>>>>>> On Wed, 14 Jan 2009 14:22:25 -0800, Jack <jack@the_wild_kingdom.com> wrote:
>>>>>>>
>>>>>>>> Ben Kaufman wrote:
>>>>>>>>> On Wed, 14 Jan 2009 12:29:49 -0800, Jack <jack@the_wild_kingdom.com> wrote:
>>>>>>>>> <SNIP>
>>>>>>>>>
>>>>>>>>>> When Israel invaded Lebanon in 2006, after several rockets were fired
>>>>>>>>>> into northern Israel and one of its patrols attacked by Hezbollah, the
>>>>>>>>>> UN estimated that 1,191 Lebanese civilians were killed and
>>>>>>>>>> 4,409 wounded. Everyone saw the images on their TV screens of Israeli
>>>>>>>>>> bombs falling into civilian areas. In this regard, the Israelis seem no
>>>>>>>>>> different than Hamas or Hezbollah.
>>>>>>>>> You omitted the fact that they were trying to rescue a soldier kidnapped by
>>>>>>>>> Hezbollah and Hezbollah was using Lebanese as human shields.
>>>>>>>>>
>>>>>>>>> Ben
>>>>>>>> And their strategy for retrieving those captured solders was to bomb
>>>>>>>> Beirut?
>>>>>>> I don't think that was the strategy. After all, it was Hezbollah who had the
>>>>>>> leisure to plan the attacks and kidnapping. Israel was reacting in an effort
>>>>>>> to rescue the kidnapped soldiers and they did make some mistakes, which they
>>>>>>> later acknowledged.
>>>>>>>
>>>>>>> Ben
>>>>>> Okay, so the Israelis are not bloodthirsty, just stupid.
>>>>> How about human and not perfect?
>>>> How about thuggish?
>>> Are you saying that is human or that they are not really human?
>> Are you trying to turn it into a race issue again?
>
> You are the one who is intent on saying that Jews are terrible,

You are an idiot, and therefore unable to distinguish between Israel and
jews. One is a country, the other is a religion.

I have not once characterized jews as terrible, and I defy you to find a
quote where I have.