On Thu, 24 Feb 2005, Peter Rabbitson wrote: > What can I use that would be as functional as WWW::Mechanize while at > the same time [Javascript aware].
To do this properly, you need to have a proper Javascript engine. I'm not aware of any Javascript hooks for Perl, but then, all modern web browsers have support for it built in, if you can leverage that. It occurs to me that the "easiest" way to do this -- for definitions of "easy" meaning "heavy, a bit complex, but with most of the hard work offloaded from you" -- would be to automate a regular web browser. What platform is this going to be running on? If you're on a Mac, you can do this with AppleScript &/or Mac::Glue, which makes this pretty easy with most browsers -- you can just have the system record your actions as you go through it once, and save the results as an AppleScript script that can be run as-is, rewritten & optimised, or redone & extended in Perl syntax with Mac::Glue. I believe that there are similar options available on Windows (Windows Script Host? OLE?) but I've never used them and can't comment on how well they play with Perl. It's probably not too bad though. On Linux or another Unix.... you may be stuck with cobbling everything together yourself there, but then as a Linux user that's how things are expected to work :-) On any platform, you might be able to get some kind of Gecko / Mozilla / Firefox / etc wrapper that uses the Gecko engine to do the work, and that (presumably) would run as some kind of in-browser plugin. This might actually be worth investigating, but it would probably involve little if any Perl code. But anyway, short of puzzling out the Javascript by hand -- which may be sufficient for limited problems -- getting help from software that can really "speak" Javascript is your best bet. Parsing this out with regular expressions is just nuts -- there's way too many ways to express the same concept in Javascript code, and anything you write that has to be reasonably robust is going to be nearly as complex as a full-blown Javascript engine would have been -- at which point you've just been wasting your time. Poking around on CPAN, I see possibly useful modules: JavaScript.pm (copyright 2001; abandoned?) and JavaScript::SpiderMonkey.pm (the readme dates to 2002, but the package has releases from Aug 2004, which isn't so bad). <http://search.cpan.org/~mschilli/JavaScript-SpiderMonkey-0.11/SpiderMonkey.pm> <http://www.cpan.org/modules/by-module/JavaScript/> <http://search.cpan.org/search?query=spidermonkey&mode=all> If you can get one of these to work, you can ignore all the stuff above about automating a web browser :-) -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
