我正在尝试使用 Mechanize 制作一个 ruby 脚本,这样我就可以登录到 Tumblr。我有以下脚本:
require 'rubygems'
require 'mechanize'
def get_page link
agent = Mechanize.new
page = agent.get(link)
end
def login email, pass
login_page = get_page 'https://www.tumblr.com/login'
dash = login_page.form_with(:action => 'https://www.tumblr.com/svc/account/register') do |f|
f.fields[0] = email
f.fields[1] = pass
end.click_button
dash
end
根据 Mechanize 网站的这段代码应该可以工作,但我总是收到这个错误:
/Users/me/.rvm/gems/ruby-2.0.0-p0/gems/mechanize-2.7.1/lib/mechanize/form.rb:312:in `block in save_hash_field_order': undefined method `node' for "email@email.com":String (NoMethodError)
谁能帮我这个?或者如果已经有一个脚本,你能指点我吗?(我没找到)