[英]Ruby Mechanize Login form submit error
require "mechanize"
a = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' }
a.get('http://erp.jecrcuniversity.edu.in:8084/jecrc_academia/') do |page|
page.form_with(name: "loginForm") do |f|
f.userId = ARGV[0]
f.password1 = ARGV[1]
end.submit
end
a.get('http://122.15.3.5:8084/jecrc_webguru/login.do') do |page|
pp page
end
I am trying to login and then redirect to the page but it keeps redirecting me the login page again. 我正在尝试登录,然后重定向到该页面,但是它一直在重新引导我登录页面。 I have also tried to do this but i still have same problem. 我也曾尝试这样做,但我仍然有同样的问题。
# jecrc_form = page.form('loginForm')
# username_field = jecrc_form.field_with(:name => 'userId')
# username_field.value = ARGV[0];
# password_field = jecrc_form.field_with(:name => 'password1')
# password_field.value = ARGV[1]
# jecrc_form.click_button
Pretty Print of my form is: 我的表格的漂亮打印内容是:
{forms
#<Mechanize::Form
{name "loginForm"}
{method "POST"}
{action "/jecrc_academia/CommonLoginCheck.do
;sessionid=1EA144A84FA0B3845126723B95634B4F"}
{fields
[hidden:0x126d9e0 type: hidden name: currentTime value: ]
[text:0x126d88c type: text name: userId value: ]
[hidden:0x126d738 type: hidden name: password value: ]
[field:0x126d5e4 type: password name: password1 value: ]}
{radiobuttons}
{checkboxes}
{file_uploads}
{buttons [button:0x126d47c type: button name: value: Login]}>}>
Here's what the browser sends: 这是浏览器发送的内容:
The password looks like a md5 and the currentTime is a base64 of a timestamp (1491879634000 in this case). 密码看起来像md5,而currentTime是时间戳的base64(在这种情况下为1491879634000)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.