ruby - 使用 Mechanize 的 Tumblr 登录脚本

标签 ruby login mechanize tumblr

我正在尝试使用 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)

谁能帮我这个?或者,如果已经有一个脚本,你能指点我吗? (我没有找到)

最佳答案

我不知道你在做什么,但使用 fields[0] 是一团糟和错误。

一般来说:

form['email'] = email
form['password'] = password
next_page = form.submit form.button

关于ruby - 使用 Mechanize 的 Tumblr 登录脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16919096/

相关文章:

ruby-on-rails - Ruby 和 Ruby on Rails 有什么区别?

php - undefined index $myusername 和 $mypassword?

python - zope.testbrowser 的代理设置

Ruby 转换日期

c++ - 在 Rails 中使用 Ruby 扩展时要考虑什么?

ruby-on-rails - 根据 Ruby 版本管理 gem 依赖项

facebook - Electron BrowserWindow Facebook 登录设置 Cookie 失败

Python - 使用用户名/密码的未命名输入标签登录到网页抓取

Ruby 内置方法从一维数组创建多维数组

powershell - PowerShell:在事件查看器中, “Access is denied”不显示为 “Audit Failure”