Код: Выделить всё
<form name=qw action=/cgi-bin/ch/cht.pl method=POST>
<table><tr><td>
<table cellspacing=0 cellpadding=0>
<tr><td align=right><B>назовитесь:  </B></td><td><input class="l" type=text name=name size=9 maxlength=20></td></tr>
<tr><td align=right><B>пароль:  </B></td><td><input class="l" type=password name=pass size=9 maxlength=15></td></tr>
</table></td>
<td>  <B>цвет: </B></td>
<td align=right>
<table border=0 cellspacing=1 cellpadding=0 height=40>
<tr>
Код: Выделить всё
#!/usr/bin/ruby
require 'rubygems'
require 'hpricot'
require 'mechanize'
agent = Mechanize.new
agent.read_timeout = 60
#agent.idle_timeout = 60
agent.open_timeout = 60
page = agent.get 'http://bizarre.kiev.ua/'
form = page.form_with( :action => '/cgi-bin/ch/cht.pl' )
username_field = form.field_with(:name => "name")
username_field.value = "hhhfghfgh"
password_field = form.field_with(:name => "pass")
password_field.value = ""
agent.submit form
ругается
Код: Выделить всё
./rub.rb:17: undefined method `field_with' for nil:NilClass (NoMethodError)
это строка:
Код: Выделить всё
username_field = form.field_with(:name => "name")