我试图将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
没有变化:表单没有提交,页面没有重定向
我错过了什么?谢谢!
答案 0 :(得分:1)
每个agent.get()
都会获得一个新页面尝试
agent.get("http://mobile.zenitbet.com/") do |p|
f = p.forms.first
f.login = 'login'
f.password = 'password'
f.submit
end