Grzegorz Kazulak
Grzegorz Kazulak

Reputation: 424

Mechanize on HTTPS site

Has anyone used the Mechanize gem on a site that required SSL?

When I try to access such a website Mechanize tries to use standard HTTP which results in endless redirections between http:// and https://.

Upvotes: 3

Views: 4385

Answers (2)

Wayne Conrad
Wayne Conrad

Reputation: 108089

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

Upvotes: 0

Evgeny Shadchnev
Evgeny Shadchnev

Reputation: 7388

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.

Upvotes: 3

Related Questions