[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

calling a javascript function with Mechanize

Rita Amritkar

1/3/2008 7:51:00 AM

Hi all,

I am using Mechanize. I can get the particular contents but I
am not getting the expected data. There is a function in javascript
as,
window.onload = function() {
if (location && location.search == "") {
location.replace('/po3/?_d');
} else {
location.replace('/po3/' + location.search + '&_d=1');
};
};

I think this function is not getting called so I am not able to get
the expected data. I want to call this function with Mechanize.

Please help me...

Thanks in advance.
3 Answers

Kamal Fariz

1/3/2008 8:25:00 AM

0

> There is a function in javascript
>
> snip
>
> I think this function is not getting called so I am not able to get
> the expected data. I want to call this function with Mechanize.

Mechanize can't evaluate javascript. The creator of Mechanize, Aaron
Patterson, is working on a new project called RKelly which has the
goal of being able to evaluate Javascript in Ruby.

Until then, your only solution is to use Selenium or Watir to control
an actual browser.

Regards,
Kamal


Jano Svitok

1/3/2008 11:24:00 AM

0

On Jan 3, 2008 9:24 AM, Kamal Fariz <kamal@ror.com.my> wrote:
> > There is a function in javascript
> >
> > snip
> >
> > I think this function is not getting called so I am not able to get
> > the expected data. I want to call this function with Mechanize.
>
> Mechanize can't evaluate javascript. The creator of Mechanize, Aaron
> Patterson, is working on a new project called RKelly which has the
> goal of being able to evaluate Javascript in Ruby.
>
> Until then, your only solution is to use Selenium or Watir to control
> an actual browser.

IIRC scrubyt uses firewatir for similar cases, so you may have better
luck using that. (http://sc...)

ilpuccio.febo@gmail.com

1/4/2008 10:13:00 AM

0

On Jan 3, 12:23 pm, Jano Svitok <jan.svi...@gmail.com> wrote:
> On Jan 3, 2008 9:24 AM, Kamal Fariz <ka...@ror.com.my> wrote:
>
> > > There is a function in javascript
>
> > > snip
>
> > > I think this function is not getting called so I am not able to get
> > > the expected data. I want to call this function with Mechanize.
>
> > Mechanize can't evaluate javascript. The creator of Mechanize, Aaron
> > Patterson, is working on a new project called RKelly which has the
> > goal of being able to evaluate Javascript in Ruby.
>
> > Until then, your only solution is to use Selenium or Watir to control
> > an actual browser.

Take a look here:
http://code.google.com/p/ruby-spi...
would be very interesting binding javascript engine directely in ruby.

> IIRC scrubyt uses firewatir for similar cases, so you may have better
> luck using that. (http://sc...)
Can you point me on that kind of example, plz?

--
Ra