#!/usr/local/bin/ruby
$:.unshift '../lib'
require "web/agent"
require "web/agent/forms"

url = ARGV.shift || 'http://rwiki.moonwolf.com/rw-cgi.cgi?cmd=edit;name=SandBox'
agent = Web::Agent.new
agent.setup()
agent.get(url)

#p agent

forms = Web::Agent::Forms.new(agent.rsp.body)

form = forms.forms[1]

p form

form.fields.each {|field|
  if field.name=='src'
    field.text = field.text + ("Now:" + Time.now.to_s + "\n\n")
  end
}

form.submit(agent)
p agent
