Forum: Ruby mechanize newbie

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
59d2de0dc2028141540521eb2360c40a?d=identicon&s=25 Colin Summers (Guest)
on 2007-06-13 23:54
(Received via mailing list)
Okay, Ruby in general newbie, but I did the whole shovell project for
RoR, so I felt I was getting somewhere...

I am fooling around trying to make a spider (scraper?) to pull content
off the Forum I read all the time so that I can read it offline.

It seemed like mechanize is exactly what I want. But I try this:

require 'rubygems'; require 'mechanize'

agent =
page = agent.get('')

pp page

puts "\n\n trying to login... \n\n"

# Fill out the login form
form  = page.forms.first
form.vb_login_username = "username"
form.vb_login_md5password = "password" ="login"
form.s = ""

page  = agent.submit(form)

pp page

# pull down a thread
page = agent.get('')

pp page

And it doesn't login (blank page for that last get). Clues?

A481c40ea2228f15dcc28c5a669faee2?d=identicon&s=25 jfry (Guest)
on 2007-06-14 00:42
(Received via mailing list)
Hi Colin, I can't tell you how to do it in mechanize, but I can say
that what you are trying to do is super easy in Watir:

Watir (Web Application Testing In Ruby) is primarily used for driving
browser-based test automation, but it has a wonderful API that makes
what you describe very easy. Originally the only choice of browser to
drive was IE, but now the FireWatir and SafariWatir projects are
getting strong as well.

Best of luck, whatever solution you go with,
F54bc341bc19c48e5860fda022663795?d=identicon&s=25 Nathan Taylor (shadowcipher)
on 2007-06-14 16:21
(Received via mailing list)

This line here

form.vb_login_md5password = "password"

Shows the form password value as being an md5password.  Are you creating
md5 hash out of your password before supplying it to mechanize?  If not
I would assume that is the problem.
59d2de0dc2028141540521eb2360c40a?d=identicon&s=25 Colin Summers (Guest)
on 2007-06-14 21:57
(Received via mailing list)

You are correct. I finally figured that part out (with some help from
someone who wrote the same sort of thing in .NET).

This topic is locked and can not be replied to.