[英]Mechanize: can't pass info
我正在尝试将login
和password
传递到站点的表单文本字段。
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
没有更改:表单不提交,页面不重定向
我错过了什么? 谢谢!
每个agent.get()都会获得一个新页面
尝试
agent.get("http://mobile.zenitbet.com/") do |p|
f = p.forms.first
f.login = 'login'
f.password = 'password'
f.submit
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.