ruby on rails - Mechanize: not logged in the site -
i'm trying authorise other site gem mechanize
my code:
def login_zenit agent = mechanize.new agent.get('http://mobile.zenitbet.com/') |p| f = p.forms.first f.login = 'login' f.fields[1].value = 'password' f.submit end agent.get('http://mobile.zenitbet.com/') redirect_to root_url end
the problem when run login_zenit
doesn't work - i'm not authorising site in web browser. although if run code in rails console
works perfectly. did create mistake? maybe there problem redirect_to root_url
?
thanks!
in general not possible. work visiting app need set appropriate cookies mobile.zenibet.com.
you have cookie values - they're within mechanize object, if extract them wouldn't able set them on right domain. if app beingness served foo.com browser allow set cookies on foo.com or subdomain of it, won't allow set cookies on arbitrary domain (see point 5 in section 5.3 of rfc)
unless app runs on subdomain of zenibet.com think out of luck
ruby-on-rails ruby ruby-on-rails-4 mechanize
No comments:
Post a Comment