From: Lee Jarvis Date: 2007-09-24T19:11:24+09:00 Subject: Mechanize problem Ok guys, ignore the ugly code. i just want this to work before i build it up. So it is very ugly and well, all round bad.. But i'll work on that after. I am using WWW::Mechanize and i'm trying to do a challenge (that i actually created).. here is the challenge: http://www.the-c0re.org/challenges/1/index.php I have written code to submit the first POST data and start the challenge, i have written code to get the values from the XML file.. But i can't seem to post these values in the original form.. You may have a better idea if you look at it.. Sorry about the code (like i said, i just want it to work) This is what i have so far: require 'rubygems' require 'mechanize' agent = WWW::Mechanize.new site = agent.get("http://www.the-c0re.org/challenges/1/index.php") form = site.forms.find{|f| f.name == "challenge"} form.fields.find{|f| f.name == 'start'}.value = 1 page = agent.submit(form, form.buttons.first) values = page.body.scan(/(.+?)<.b>/) link = page.body.scan(/href="(.+?)">/) xml = agent.get link arr = Array.new values.each {|v| arr.push(xml.body.scan(/<#{v}>(.+?)<\/#{v}>/)) } form = page.forms.find{|f| f.name == "challenge"} form.fields.find{|f| f.name == 'answer'}.value = arr.join(' ') newpage = agent.submit(form, form.buttons.first) this is the error i get: undefined method `value=' for nil:NilClass (NoMethodError) I don't see why though, the variable page holds the page with the correct form data and correct form names, So i have no clue.. Sorry if i haven't explained myself enough.. Thanks for anything you can give -- Posted via http://www.ruby-forum.com/.