# Looking for Mechanize code for login

**URL:** <https://www.ruby-forum.com/t/looking-for-mechanize-code-for-login/63770>\
**Category:** Ruby\
**Created:** [June 19, 2006, 2:30am UTC](https://www.ruby-forum.com/t/looking-for-mechanize-code-for-login/63770 "2006-06-19T02:30:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sauy7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecc23a/32.png) [@sauy7](https://www.ruby-forum.com/u/sauy7)\
**Post date:** [June 19, 2006, 2:30am UTC](https://www.ruby-forum.com/t/looking-for-mechanize-code-for-login/63770/1 "2006-06-19T02:30:54Z")

</div>

Hi

I am trying to automate collecting balances from my bank using  
Mechanize.  
I have set

#!/usr/bin/env ruby

require ‘rubygems’  
require ‘mechanize’  
require ‘pp’

username = “\*\*\*\*\*”  
password = “\*\*\*\*”

site\_url = “[https://online.compassweb.com/servlet/compass/login.jsp](https://online.compassweb.com/servlet/compass/login.jsp)”  
agent = WWW::Mechanize.new  
page = agent.get(site\_url)  
form = page.forms.first  
form.fields.name(“UserName”).value = username  
form.fields.name(“Password”).value = password  
page = agent.submit(form, form.buttons.first)

The page I get back has the following in it:

Can someone tell me what the process is for retrieving pages like  
this are?

Thanks

Jim F.

---

<div class="post-metadata">

**Author:** ![sauy7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecc23a/32.png) [@sauy7](https://www.ruby-forum.com/u/sauy7)\
**Post date:** [June 19, 2006, 9:54am UTC](https://www.ruby-forum.com/t/looking-for-mechanize-code-for-login/63770/2 "2006-06-19T09:54:17Z")

</div>

Jim F. wrote:

> Can someone tell me what the process is for retrieving pages like this are?  
> If that’s all you ever get back, I’d say to first do the login to get  
> the cookies, check that you get what you’re expecting back, then just  
> directly agent.get that url.

---

<div class="post-metadata">

**Author:** ![sauy7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecc23a/32.png) [@sauy7](https://www.ruby-forum.com/u/sauy7)\
**Post date:** [June 19, 2006, 3:18pm UTC](https://www.ruby-forum.com/t/looking-for-mechanize-code-for-login/63770/3 "2006-06-19T15:18:17Z")

</div>

There’s a much easier way … buy Quicken :). Or reverse-engineer  
Gnucash, if it works with your bank. 🙂

Alex Y. wrote:

> > require ‘mechanize’  
> > form.fields.name(“Password”).value = password
> > 
> > Can someone tell me what the process is for retrieving pages like  
> > this are?  
> > If that’s all you ever get back, I’d say to first do the login to get  
> > the cookies, check that you get what you’re expecting back, then just  
> > directly agent.get that url.

–  
M. Edward (Ed) Borasky

> **[世界杯竞猜彩票-世界杯官网竞猜（集团）有限公司](http://www.linuxcapacityplanning.com/)**
>
> 世界杯竞猜彩票一直以来遵守商业道德，世界杯官网竞猜坚持诚信为本，保证诚实经营。世界杯竞猜彩票先后成为安徽省电子商务协会理事单位、安徽省网商协会会员单位、合肥市电子商务协会理事单位、合肥市服务外包行业协会会员单位、安徽省云计算产业促进会会员单位。世界杯官网竞猜一直保持良好的技术及服务态度，更好地为客户服务。
