views:

391

answers:

2

Have any of you guys/girls have used ruby's Mechanize library on a site that required SSL? The problem I'm experiencing at the minute is that when I try to access such a website the mechanize tries to use standard http protocol which results in endless redirections between http// and https://

A: 

I just gave mechanize a try with my company's web site. The home page is http, but it contains a link, "customer login," which sends the browser to an https page. It worked fine. The code is:

#!/usr/bin/ruby1.8

require 'rubygems'
require 'mechanize'

agent = WWW::Mechanize.new
page = agent.get("http://www.not_the_real_url.com")
link = page.link_with(:text=>"CUSTOMER LOGIN")
page = link.click
form = page.forms.first
form['user_login'] = 'not my real login name'
form['user_password'] = 'not my real password'
page = form.submit
Wayne Conrad
+1  A: 

Mechanize works just fine with https. Try setting

agent.log = Logger.new(STDOUT)

to see what's going on between Mechanize and the server. If you are still having trouble, post a sample of the code and somebody will help.

Evgeny Shadchnev