Yann
Yann

Reputation: 3

Mechanize in Jquery

I am adept in Ruby WWW::Mechanize. And I was wondering if a jQuery equilavent exists ?

Upvotes: 0

Views: 745

Answers (2)

Mojo2Go
Mojo2Go

Reputation: 26

It's not a crazy question after all! Take a look at this link. Mr. Anand sort of injects JQuery into his Mechanize page object, then uses JQuery pretty much in-line.

http://www.s-anand.net/blog/automating-internet-explorer-with-jquery/

Don't get distracted; it's a fascinating blog.

Upvotes: 1

Nick Craver
Nick Craver

Reputation: 630369

There's not really an equivalent of this because of what it does. Mechanize going to various sites, the very basic requirement for what it does simply isn't allowed in JavaScript for security reasons. Making cross-domain requests is blocked by something called the same-origin policy.

You can't make requests (and get the data back, through the request gets there) from a domain different than the one of the page you're on, this is to prevent malicious JavaScript from doing things like spam https://mybank.com with login attempts, among many other examples.

If you want something besides Mechanize for your needs, you'll have to either customize a browser and kill the SOP security, or look outside the browser like you're already doing...but since the policies are there by default, I don't believe any JS framework like this exists (that I've ever seen/heard of anyway).

Upvotes: 1

Related Questions