I need to parse the form to get the value of `IW_SessionID_from the HTML I get back, which I can't get to work.
#!/usr/bin/ruby
require 'pp'
require 'nokogiri'
require 'mechanize'
r = '<HTML><HEAD><TITLE></TITLE><meta http-equiv=\"cache-control\" content=\"no-cache\">\r\n<meta http-equiv=\"pragma\" content=\"no-cache\">\r\n<NOSCRIPT><HTML><BODY>Your browser does not seem to support JavaScript. Please make sure it is supported and activated</BODY></HTML></NOSCRIPT>\r\n<SCRIPT>\r\nvar ie4 = (document.all)? true:false;\r\nvar ns6 = (document.getElementById)? true && !ie4:false;\r\nfunction Initialize() {\r\nvar lWidth;\r\nvar lHeight;\r\nif (ns6) {\r\n lWidth = window.innerWidth - 30;\r\n lHeight = window.innerHeight - 30;\r\n} else {\r\n lWidth = document.body.clientWidth;\r\n lHeight = document.body.clientHeight;\r\n if (lWidth == 0) { lWidth = undefined;}\r\n if (lHeight == 0) { lHeight = undefined;}\r\n}\r\ndocument.forms[0].elements[\"IW_width\"].value = lWidth;\r\ndocument.forms[0].elements[\"IW_height\"].value = lHeight;\r\ndocument.forms[0].submit();\r\n}</SCRIPT></HEAD><BODY onload=\"Initialize()\">\r\n<form method=post action=\"/bwtem\">\r\n<input type=hidden name=\"IW_width\">\r\n<input type=hidden name=\"IW_height\">\r\n<input type=hidden name=\"IW_SessionID_\" value=\"1wqzj1f0vec57r1apfqg51wzs88c\">\r\n<input type=hidden name=\"IW_TrackID_\" value=\"0\">\r\n</form></BODY></HTML>'
page = Nokogiri::HTML r
puts page.css('form[name="IW_SessionID_"]')
a = Mechanize.new
page2 = Mechanize::Page.new(nil,{'content-type'=>'text/html'},r,nil,a)
pp page2.form_with(:name => "IW_SessionID_")
The script just returns nil
.
Can anyone figure out how to get the value of IW_SessionID_
?