【问题标题】:Mechanize: can't pass info机械化:无法传递信息
【发布时间】:2014-06-16 14:17:08
【问题描述】:

我正在尝试将 loginpassword 传递给网站的表单文本字段。

require 'mechanize'

agent = Mechanize.new

agent.get("http://zenitbet.com/").forms.first

 => #<Mechanize::Form
 {name nil}
 {method "POST"}
 {action "index.php"}
 {fields
  [text:0x3fc34da544c0 type: text name: login value: ]
  [field:0x3fc34da5418c type: password name: imd5 value: ]}
 {radiobuttons}
 {checkboxes}
 {file_uploads}
 {buttons [submit:0x3fc34da53d90 type: submit name:  value: войти]}>

当我试图传递类似的信息时

agent.get("http://mobile.zenitbet.com/").forms.first.login = "login"
agent.get("http://mobile.zenitbet.com/").forms[0].fields[1].value = "password"

并提交

agent.get("http://mobile.zenitbet.com/").forms[0].submit

没有变化:表单不提交,页面不重定向

我错过了什么?谢谢!

【问题讨论】:

    标签: ruby-on-rails ruby mechanize


    【解决方案1】:

    每个 agent.get() 都会获得一个新页面

    试试

    agent.get("http://mobile.zenitbet.com/") do |p|
      f = p.forms.first
      f.login = 'login'
      f.password = 'password'
      f.submit
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-29
      • 2017-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多