KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to use the Ruby version of Mechanize to extract my employer's tickets from a ticket management system that we're moving away from that does not supply an API. Problem is, it seems Mechanize isn't keeping the cookies between the post call and the get call shown below: require 'rubygems' require 'nokogiri' require 'mechanize' @agent = Mechanize.new page = @agent.post('http://<url>.com/user_session', { 'authenticity_token' => '<token>', 'user_session[login]' => '<login>', 'user_session[password]' => '<password>', 'user_session[remember_me]' => '0', 'commit' => 'Login' }) page = @agent.get 'http://<url>.com/<organization>/<repo-name>/tickets/1' puts page.title user_session is the URL to which the site's login page POSTs, and I've verified that this indeed logs me in. But the page that returns from the get call is the 'Oops, you're not logged in!' page. I've verified that click ing links on the page that returns from the post call works, but I can't actually get to where I need to go without JavaScript. And of course I've done this successfully on the browser with the same login. What am I doing wrong?
Tags (comma-separated)
Save Edits
Cancel