我有一个登录表单的页面。登录后有一些重定向。第一个看起来像这样:
#<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>>
所以当我在这里做一个 page.class 我得到
Mechanize::File
我如何将其转换为Mechanize::Page
?
@pguardiario
为了更好地解释,我将原始消息中的代码存储在 page.
当我做 page.class 我得到 Mechanize::File
那么我执行上面的代码:
agent = Mechanize.new
agent.post_connect_hooks << lambda {|http| http[:response].content_type = 'text/html'}
所以我这样做:agent.get(page.uri.to_s) 或事件尝试使用任何 url agent.get(" https://www.manageyourloans.com/MYL ") 我收到一个错误:ArgumentError: wrong number of arguments (4对1)
我什至试过这个:
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
}
}
我的问题是,一旦我这样做了,如何将上一页转换为 Mechanize::Page?