require 'rubygems'
require 'mechanize'
agent = WWW::Mechanize.new
agent.user_agent_alias = 'Windows IE 7'
page = agent.post("http://sso.chinaunix.net/Login?")
form = page.forms[0]
form['login_name'] = 'luofeiyu'
form['password'] = 'qwerty'
page = agent.submit(form)
page.save("/home/pt/web")

irb(main):166:0>  form = page.forms[0]
=> nil
irb(main):167:0>  form['login_name'] = 'luofeiyu'
NoMethodError: undefined method `[]=' for nil:NilClass
from (irb):167
from :0
irb(main):168:0>  form['password'] = 'qwerty'
NoMethodError: undefined method `[]=' for nil:NilClass
from (irb):168
from :0
irb(main):169:0>  page = agent.submit(form)
ArgumentError: wrong number of arguments (0 for 1)
from /var/lib/gems/1.8/gems/mechanize-1.0.0/lib/mechanize.rb:368:in
`method'
from /var/lib/gems/1.8/gems/mechanize-1.0.0/lib/mechanize.rb:368:in
`submit'
from (irb):169
from :0
would you mind to tell me what wrong is?
-- 
Posted via http://www.ruby-forum.com/.