Ruby 使用mechanizegem登录

Ruby 使用mechanizegem登录,ruby,authentication,mechanize,Ruby,Authentication,Mechanize,它返回并返回一个错误.Net::HTTPUnauthorized。如果有其他方法在弹出框中填充凭证,请建议我 我检查了,它提示进行基本验证。你必须先输入它 My code is this require 'mechanize' obj=Mechanize.new a.get("http://cafedepoca.com/submit_data?name=test&email=test@mail.com&pass=mypassword&prof_type=30

它返回并返回一个错误.Net::HTTPUnauthorized。如果有其他方法在弹出框中填充凭证,请建议我

我检查了,它提示进行基本验证。你必须先输入它

My code is this


 require 'mechanize'
  obj=Mechanize.new
  a.get("http://cafedepoca.com/submit_data?name=test&email=test@mail.com&pass=mypassword&prof_type=30&api_key=mykey") do |d|
  d.user='testuser'
  d.password='mypassword'
  end.click_button
它应该是这样工作的。

我检查了,它会提示基本身份验证。你必须先输入它

My code is this


 require 'mechanize'
  obj=Mechanize.new
  a.get("http://cafedepoca.com/submit_data?name=test&email=test@mail.com&pass=mypassword&prof_type=30&api_key=mykey") do |d|
  d.user='testuser'
  d.password='mypassword'
  end.click_button
它应该是这样工作的。

您需要使用或通过基本身份验证

 require 'mechanize'
 a=Mechanize.new
 a.auth('username','password') # fix this line with correct login and password for BasicAuth  
 a.get("http://cafedepoca.com/submit_data?name=test&email=test@mail.com&pass=mypassword&prof_type=30&api_key=mykey").click_button
您需要使用或通过基本身份验证

 require 'mechanize'
 a=Mechanize.new
 a.auth('username','password') # fix this line with correct login and password for BasicAuth  
 a.get("http://cafedepoca.com/submit_data?name=test&email=test@mail.com&pass=mypassword&prof_type=30&api_key=mykey").click_button

您的案例中的“a”是什么?当我填充值时,它返回ouath Net::HTTPUnauthorized error在您的案例中的“a”是什么?当我填充值时,它返回ouath Net::HTTPUnauthorized error