[英]Mechanize: can't pass info
I'm trying to pass login
and password
to the form textfields of the site. 我正在尝试将
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: войти]}>
When I'm trying to pass info like 当我尝试传递信息时
agent.get("http://mobile.zenitbet.com/").forms.first.login = "login"
agent.get("http://mobile.zenitbet.com/").forms[0].fields[1].value = "password"
and submit it 并提交
agent.get("http://mobile.zenitbet.com/").forms[0].submit
there is no changes: form doesn't submit and page doesn't redirect 没有更改:表单不提交,页面不重定向
What did I miss? 我错过了什么? Thanks!
谢谢!
You are getting a fresh page each agent.get() 每个agent.get()都会获得一个新页面
Try 尝试
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.