我有一个简单的任务,我想使用机械化来完成,但是网站上有一个登录页面,要求您输入电子邮件,然后在您输入并单击提交后,在同一页面上要求输入密码。我将如何处理同一页面上的第二个提交?
我尝试了这个: 任务:estimatesite =>:environment do 需要“机械化”
mechanize = Mechanize.new
page = mechanize.get('https://estimatesite.com/auth/login')
form = page.forms.first
form['user_search_email[email]'] = 'myemail@email.com'
form['check_distinct_user_password[plainPassword]'] = 'mypassword'
page = form.submit
end
它看起来像这样:
task :estimatesite => :environment do
require 'mechanize'
mechanize = Mechanize.new
page = mechanize.get('https://estimatesite.com/auth/login')
form = page.forms.first
form['user_search_email[email]'] = 'myemail@email.com'
page = form.submit
form['check_distinct_user_password[plainPassword]'] = 'mypassword'
page = form.submit
end
但似乎都不起作用
答案 0 :(得分:0)
task :estimatesite => :environment do
require 'mechanize'
agent = WWW::Mechanize.new
agent.get('https://estimatesite.com/auth/login')
form = agent.page.forms.first
form['user_search_email[email]'] = 'myemail@email.com''
form.submit
form['check_distinct_user_password[plainPassword]'] = 'mypassword'
form.submit
end
参考=>