I'm sending the following to populate a search box on a site through mechanize.
@codes = ['123', '456']
This is my mech code:
@codes.each do |x|
mech = Mechanize.new
aliases = ['Linux Mozilla', 'Mac Firefox', 'Mac Mozilla',
'Windows Mozilla', 'Linux Firefox', 'Mac Safari', 'Linux Konqueror']
aliases.shuffle!
mech.user_agent_alias = "#{aliases[0]}"
mech.get('http://www.a_url.com')
mech.page.forms[0]["field-keywords"] = "#{x}"
mech.page.forms[0].submit
try = mech.page.link_with(:text => "Product Details").click
url = try.parser
When it gets to here, it works with one code, but breaks with more than one code from @codes
:
match_on = "colorImages': "
end_on = ", "
pic_1 = /#{match_on}.*?#{end_on}/m.match(url).to_s
Can't figure out why.
Fixed it.. It was how I passed string variables and not the parser or Mech.