Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Having problem using Mechanize to log into Google Account

Reply
Thread Tools

Having problem using Mechanize to log into Google Account

 
 
Kevin Lee
Guest
Posts: n/a
 
      06-11-2007
I am struggling with Mechanize to login to my Google account. Here is
my code:

agent = WWW::Mechanize.new
page = agent.get('https://www.google.com/accounts/ServiceLogin?....')
# or http://www.google.com/calendar

google_form = page.forms[0]
google_form.fields.name("Email").first.value = 'myaddress'
google_form.fields.find {|f| f.name == 'Passwd'}.value = 'mypasswd'

pp page
results = agent.submit(google_form, google_form.buttons.first)
pp page
puts results.body

The values of the Email and Passwd fields remain empty. So it appears
to me that the code fails to login. What more should I do? Please
help!

Thanks in advance!

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Peter Szinek
Guest
Posts: n/a
 
      06-11-2007
Kevin,

> The values of the Email and Passwd fields remain empty. So it appears
> to me that the code fails to login. What more should I do? Please
> help!


Mechanize can not handle Javascript, so it won't work this way. You have
two options here:

1) Scrape the non-JS page - check this article:

http://schf.uc.org/articles/2007/02/...ze-and-hpricot

2) Use Watir (FireWatir if you are not on win32) which can handle
JavaScript.

btw, posting mechanize related questions to the mechanize list
((E-Mail Removed)) can yield better response time/quality.

HTH,
Peter
_
http://www.rubyrailways.com :: Ruby and Web2.0 blog
http://scrubyt.org :: Ruby web scraping framework
http://rubykitchensink.ca/ :: The indexed archive of all things Ruby.




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get redirect log in Mechanize? Rodion Raskolnikov Ruby 0 08-30-2009 09:59 AM
error in sending post to log in google account lanclot C Programming 5 11-25-2007 11:40 PM
Bounty: $250 - Successfully log in to AOL Webmail with Mechanize dave.myron@contentfree.com Ruby 11 11-04-2007 08:25 AM
having trouble viewing the google homepage i have to sign into dezandlaurie@gmail.com Computer Support 0 05-20-2007 06:50 PM
cannot log into my account hpfnorthwest@gmail.com Computer Support 7 11-02-2005 10:40 PM



Advertisments