Using Mechanize and hpricot to get property taxes

Discussion in 'Ruby' started by Cy Gar, May 18, 2008.

  1. Cy Gar

    Cy Gar Guest

    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. i 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. I tried page =
    agent.submit(form) also to no avail. What am I doing wrong?

    Two side questions: How do you auto-indent ruby code? I am using SciTe
    editor and i find myself using my old matlab editor every once in a
    while to beautify the codes. Hw could ruby not have auto-indentor?
    Also quick way of turning an html table into a matrix, array of arrays?
    thanks in advance.


    require 'rubygems'
    require 'hpricot'
    require 'mechanize'
    agent = WWW::Mechanize.new
    apn='2264-011-027'
    page =
    agent.get('https://ttc.lacounty.gov/secured_asp/vcheck_new/index.php')
    form=page.forms.with.name("pageform").first
    form['mapbook']=apn[0,4]
    form.page=apn[5,3]
    form.parcel=apn[9,3]
    page = agent.submit(form,form.buttons.first) #gives error

    error:

    c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize/page.rb:104:in
    `bases': undefined method `search' for nil:NilClass (NoMethodError)
    from
    c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize.rb:440:in
    `to_absolute_uri'
    from
    c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize.rb:659:in
    `fetch_page'
    from
    c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize.rb:466:in
    `post_form'
    from
    c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize.rb:269:in
    `submit'
    --
    Posted via http://www.ruby-forum.com/.
     
    Cy Gar, May 18, 2008
    #1
    1. Advertising

  2. Cy Gar

    Guest

    Re: Using Mechanize and hpricot to get property taxes

    On 18 Mai, 22:15, Cy Gar <> 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.  i 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.  I tried page =
    > agent.submit(form) also to no avail. What am I doing wrong?
    >
    > Two side questions: How do you auto-indent ruby code?  I am using SciTe
    > editor and i find myself using my old matlab editor every once in a
    > while to beautify the codes.  Hw could ruby not have auto-indentor?
    > Also quick way of turning an html table into a matrix, array of arrays?
    > thanks in advance.
    >
    >   require 'rubygems'
    >   require 'hpricot'
    >   require 'mechanize'
    >   agent = WWW::Mechanize.new
    >   apn='2264-011-027'
    >   page =
    > agent.get('https://ttc.lacounty.gov/secured_asp/vcheck_new/index.php')
    >   form=page.forms.with.name("pageform").first
    >   form['mapbook']=apn[0,4]
    >   form.page=apn[5,3]
    >   form.parcel=apn[9,3]
    >   page = agent.submit(form,form.buttons.first)  #gives error
    >
    > error:
    >
    > c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize/page.rb:104:in
    > `bases': undefined method `search' for nil:NilClass (NoMethodError)
    >   from
    > c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize.rb:440:in
    > `to_absolute_uri'
    >   from
    > c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize.rb:659:in
    > `fetch_page'
    >   from
    > c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize.rb:466:in
    > `post_form'
    >   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 = agent.submit(form,form.buttons.first)

    => #<WWW::Mechanize::page
    {url
    #<URI::HTTPS:0xfdbb0484c URL:https://ttc.lacounty.gov/secured_asp/
    vcheck_new/index.php?
    page=installments&SSID=3an61rbfpbje0uunii667oj706>}
    {meta}
    {title "Property Tax Payment Status Page"}
    {iframes}
    {frames}
    {links
    #<WWW::Mechanize::Link
    "Select Another Parcel"
    "index.php?page=main&SSID=3an61rbfpbje0uunii667oj706">
    #<WWW::Mechanize::Link
    "\r\n \r\n "
    "index.php?page=main&SSID=3an61rbfpbje0uunii667oj706">}
    {forms}>
     
    , May 18, 2008
    #2
    1. Advertising

  3. Cy Gar 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. i 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. I tried page =
    > agent.submit(form) also to no avail. What am I doing wrong?
    >
    > Two side questions: How do you auto-indent ruby code? I am using SciTe
    > editor and i find myself using my old matlab editor every once in a
    > while to beautify the codes.


    With Scite once you name the file name.rb or select Ruby from the
    language tab it should automatically handle the indentations.


    Hw could ruby not have auto-indentor?
    > Also quick way of turning an html table into a matrix, array of arrays?
    > thanks in advance.
    >
    >
    > require 'rubygems'
    > require 'hpricot'
    > require 'mechanize'
    > agent = WWW::Mechanize.new
    > apn='2264-011-027'
    > page =
    > agent.get('https://ttc.lacounty.gov/secured_asp/vcheck_new/index.php')
    > form=page.forms.with.name("pageform").first
    > form['mapbook']=apn[0,4]
    > form.page=apn[5,3]
    > form.parcel=apn[9,3]
    > page = agent.submit(form,form.buttons.first) #gives error
    >
    > error:
    >
    > c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize/page.rb:104:in
    > `bases': undefined method `search' for nil:NilClass (NoMethodError)
    > from
    > c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize.rb:440:in
    > `to_absolute_uri'
    > from
    > c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize.rb:659:in
    > `fetch_page'
    > from
    > c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize.rb:466:in
    > `post_form'
    > from
    > c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.7.6/lib/www/mechanize.rb:269:in
    > `submit'
     
    Michael W. Ryder, May 18, 2008
    #3
  4. Cy Gar

    Cy Gar Guest

    By auto-indent, i meant indenting an entire chunk of the code not indent
    after each return hit. thanks! In matlab medit, you can highlite the
    entire code block and use cntrl-I to indent the entire section.. In
    unix, cb is run to beautify c code.


    Michael W. Ryder wrote:
    > With Scite once you name the file name.rb or select Ruby from the
    > language tab it should automatically handle the indentations.
    >

    --
    Posted via http://www.ruby-forum.com/.
     
    Cy Gar, May 18, 2008
    #4
  5. Cy Gar

    Cy Gar Guest

    Re: Using Mechanize and hpricot to get property taxes

    Hey Thanks! But what the heck? I just reinstalled ruby gems, hpricot and
    mechanize and still got the same error?? running from sciTe.


    unknown wrote:

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

    --
    Posted via http://www.ruby-forum.com/.
     
    Cy Gar, May 19, 2008
    #5
  6. Cy Gar

    Avdi Grimm Guest

    Re: Using Mechanize and hpricot to get property taxes

    On Sun, May 18, 2008 at 6:56 PM, Cy Gar <> wrote:
    > By auto-indent, i meant indenting an entire chunk of the code not indent
    > after each return hit. thanks! In matlab medit, you can highlite the
    > entire code block and use cntrl-I to indent the entire section.. In
    > unix, cb is run to beautify c code.


    I know that Emacs, Netbeans, and TextMate all do this for Ruby code.
    I'm sure other editors do as well.

    --
    Avdi

    Home: http://avdi.org
    Developer Blog: http://avdi.org/devblog/
    Twitter: http://twitter.com/avdi
    Journal: http://avdi.livejournal.com
     
    Avdi Grimm, May 19, 2008
    #6
  7. Cy Gar

    Cy Gar Guest

    Re: Using Mechanize and hpricot to get property taxes

    I tried it using fxri and i think the output you're showing is for first
    agent.get call:
    page =
    agent.get('https://ttc.lacounty.gov/secured_asp/vcheck_new/index.php')

    not the submit line. I still get an error on that line.


    unknown wrote:

    > Just pasted it into irb. I don't run into errors...
    >
    >>> page = agent.submit(form,form.buttons.first)

    > => #<WWW::Mechanize::page
    > {url
    > #<URI::HTTPS:0xfdbb0484c URL:https://ttc.lacounty.gov/secured_asp/
    > vcheck_new/index.php?
    > page=installments&SSID=3an61rbfpbje0uunii667oj706>}
    > {meta}
    > {title "Property Tax Payment Status Page"}
    > {iframes}
    > {frames}

    --
    Posted via http://www.ruby-forum.com/.
     
    Cy Gar, May 19, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roedy Green

    Computing sales taxes

    Roedy Green, May 8, 2010, in forum: Java
    Replies:
    15
    Views:
    595
    Arne Vajhøj
    May 13, 2010
  2. Peter Szinek
    Replies:
    2
    Views:
    159
    Peter Szinek
    Feb 21, 2007
  3. Replies:
    6
    Views:
    319
    Stefan Mahlitz
    Aug 16, 2007
  4. Ehud Rosenberg
    Replies:
    2
    Views:
    145
    Ehud Rosenberg
    Nov 14, 2007
  5. Just Another Victim of the Ambient Morality

    How can one get the Hpricot DOM document from Mechanize?

    Just Another Victim of the Ambient Morality, Sep 13, 2008, in forum: Ruby
    Replies:
    3
    Views:
    110
    Aaron Patterson
    Sep 18, 2008
Loading...

Share This Page