SPUG: programmatically managing cookies

Adam Monsen haircut at gmail.com
Fri Jan 9 13:54:32 PST 2009

On Fri, Jan 9, 2009 at 12:45 PM, Joel Grow wrote:
> I'd like to programmatically access a password-protected site.  When I GET
> the url, I receive back HTML with a javascript relay to a login page, and a
> cookie.  I do have credentials for the site.  So I can POST my
> username/password to the login page, but I need to manage the cookie the
> site sets so that I can then be forwarded to the password-protected area.
> Before I dive too deeply into this, does anyone have advice/pointers on the
> best way to manage this?

I'm a fan of WWW::Mechanize, but apparently it can't do JavaScript
besides window.open().

Some ideas:
* add a JavaScript interpreter to WWW::Mechanize
* use Selenium RC and Perl client driver
* the Ruby version of WWW::Mechanize might support JavaScript, I'm not sure

Out of those, I know that Selenium can handle JavaScript since it
drives a bona fide Web browser. Also, you can prototype your Web
actions (with record/playback) in the Selenium IDE.

I recently gave a talk on Selenium. Slides are available, if you're
interested: http://adammonsen.com/talks . The examples are in Python,
but there's really nothing fancy--they should be easily portable to

Adam Monsen

More information about the spug-list mailing list