[Mechanize-users] ruby (mechanize , net/http)

Aaron Starr astarr at wiredquote.com
Tue Jun 30 15:45:25 EDT 2009


Vlad,

This regular expression:

>
> %r{/switch_accounts.html/}
>

doesn't match this href:

>
> https://.../reports/switch_accounts.html?...
>

Because the regular expression has a trailing '/' after the
accounts.html. I think you could just change to this:

%r{/switch_accounts.html}

and get a match.

Also, something that I do which is useful for me, is to load a copy of
the page in irb, using something like this:

irb> page = Mechanize::Page.new(nil, {'content-type' => 'text/html'},
File.read('my.html'), 200)

(From memory, may have a detail wrong.)

Then, you can test your mechanize code interactively against the page,
and make sure it's working the way you expect, before you put it in
real code.

Aaron


More information about the Mechanize-users mailing list