I have a page that logs into a form. After logging in there are a few redirects. The first one looks like this:
#<Mechanize::File:0x1f4ff23 @filename="MYL.html", @code="200", @response={"cache-control"=>"no-cache=\"set-cookie\"", "content-length"=>"114", "set-cookie"=>"JSESSIONID=GdJnPVnhtN91KZfQPc3QzM1NLCyWDsnyvpGg8LL0Knnz3RgqxLFs!1803804592!-2134626567; path=/; secure, COOKIE_TEST=Aslyn; secure", "x-powered-by"=>"Servlet/2.4 JSP/2.0"}, @body="\r\n<html>\r\n <head>\r\n <meta http-equiv=\"refresh\" content=\"0;URL=MYL?Select=OK&StateName=38\">\r\n </head>\r\n</html>", @uri=#<URI::HTTPS:0x16e1eff URL:https://www.manageyourloans.com/MYL?StateName=global_CALMLandingPage&GUID=D1704621-1994-E076-460A-10B2B682B960>>
so when I do a page.class here I get
Mechanize::File
How do I convert that to a Mechanize::Page
?
@pguardiario
To better explain I have the code in my original message is stored in page.
When I do page.class I get Mechanize::File
So then I excute your code above:
agent = Mechanize.new
agent.post_connect_hooks << lambda {|http| http[:response].content_type = 'text/html'}
So I do this: agent.get(page.uri.to_s) or event try with any url agent.get("https://www.manageyourloans.com/MYL") I get an error: ArgumentError: wrong number of arguments (4 for 1)
I've even tried this:
agent = Mechanize.new { |a|
a.post_connect_hooks << lambda { |_,_,response,_|
if response.content_type.nil? || response.content_type.empty?
response.content_type = 'text/html'
end
}
}
My question is once I do this, how do I convert the previous page into a Mechanize::Page?