On 18 Mai, 22:15, Cy Gar <i... / bibotu.com> wrote:
> after reading about hpricot, mechanize and htree gems, I made an attempt
> to write a simple code to grab property tax info for homes in Los
> Angeles. =A0i wrote this fragment which goes to the assessor's website,
> finds the form entries and correctly puts in an apn number (property
> parcel number) but fails at the submit line. =A0I tried page =3D
> agent.submit(form) also to no avail. What am I doing wrong?
>
> Two side questions: How do you auto-indent ruby code? =A0I am using SciTe
> editor and i find myself using my old matlab editor every once in a
> while to beautify the codes. =A0Hw could ruby not have auto-indentor?
> Also quick way of turning an html table into a matrix, array of arrays?
> thanks in advance.
>
> =A0 require 'rubygems'
> =A0 require 'hpricot'
> =A0 require 'mechanize'
> =A0 agent =3D WWW::Mechanize.new
> =A0 apn=3D'2264-011-027'
> =A0 page =3D
> agent.get('https://ttc.lacounty.gov/secured_asp/vcheck_new/index.php')
> =A0 form=3Dpage.forms.with.name("pageform").first
> =A0 form['mapbook']=3Dapn[0,4]
> =A0 form.page=3Dapn[5,3]
> =A0 form.parcel=3Dapn[9,3]
> =A0 page =3D agent.submit(form,form.buttons.first) =A0#gives error
>
> error:
>
> c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize/page.rb:1=
04:in
> `bases': undefined method `search' for nil:NilClass (NoMethodError)
> =A0 from
> c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize.rb:440:in=

> `to_absolute_uri'
> =A0 from
> c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize.rb:659:in=

> `fetch_page'
> =A0 from
> c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize.rb:466:in=

> `post_form'
> =A0 from
> c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize.rb:269:in=

> `submit'
> --
> Posted viahttp://www.ruby-forum.com/.

Just pasted it into irb. I don't run into errors...

>> page =3D agent.submit(form,form.buttons.first)
=3D> #<WWW::Mechanize::Page
 {url
  #<URI::HTTPS:0xfdbb0484c URL:https://ttc.lacounty.gov/secured_asp/
vcheck_new/index.php?
page=3Dinstallments&SSID=3D3an61rbfpbje0uunii667oj706>}
 {meta}
 {title "Property Tax Payment Status Page"}
 {iframes}
 {frames}
 {links
  #<WWW::Mechanize::Link
   "Select Another Parcel"
   "index.php?page=3Dmain&SSID=3D3an61rbfpbje0uunii667oj706">
  #<WWW::Mechanize::Link
   "\r\n        \r\n    "
   "index.php?page=3Dmain&SSID=3D3an61rbfpbje0uunii667oj706">}
 {forms}>