This post originated from an RSS feed registered with Ruby Buzz
by Michael Neumann.
Original Post: WWW::Mechanize alike in Ruby
Feed Title: Mike's Weblog
Feed URL: http://www.ntecs.de/blog-old/index.rss?cat=ruby&count=7
Feed Description: Blogging about Ruby and other interesting stuff.
I hacked up a little library which I use in some small projects to automate
login into web-pages, extracting data from them and similar things.
Web::Unit didn’t work for my purposes, and it was easier to reinvent
the wheel than to hack Web::Unit (of course I first tried to hack
it…).
It depends on narf-lib (>= 0.6.3), more exactly, it’s version of
htmltools, and requires ruby-current (due to limitations in the net/http
library of 1.8.2). If you want to try it out with Ruby 1.8.2, just get the
net/*.rb files from ruby-current and use these instead.
Features
Cookies (very preliminary, no expire etc.)
automatic redirect
Forms, Links
Be aware that it’s just a few-hour hack, to get my project done.
It’s still very generic and misses lots of usability methods. For
example, I use find all the time, or have to pass the link that
should be clicked to method click.
Example
Here’s a simple example, that logs into your rubyforge.org acount
(pass your username and password as command-line argument).