Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Having problem using Mechanize to log into Google Account
Kevin Lee
6/11/2007 3:01:00 AM
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.co...
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-...
.
1 Answer
Peter Szinek
6/11/2007 8:08:00 AM
0
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/14/scraping-gmail-with-mechanize-a...
2) Use Watir (FireWatir if you are not on win32) which can handle
JavaScript.
btw, posting mechanize related questions to the mechanize list
(mechanize-users@rubyforge.org) can yield better response time/quality.
HTH,
Peter
_
http://www.rubyra...
:: Ruby and Web2.0 blog
http://s...
:: Ruby web scraping framework
http://rubykitch...
:: The indexed archive of all things Ruby.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Having problem using Mechanize to log into Google Account
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password