3

I'm trying to use mechanize to fill out a very simple form that lacks a name. I need to feed some numbers into three fields and acquire the output. The question of how to fill a form with no defined name has been answered a number of times (e.g. here and here), but the solutions offered do not work for me. If I run my script:

from mechanize import Browser

br = Browser()
br.open( "http://bessel.vlbi-astrometry.org/bayesian" )

br.select_form(nr=0)
br.form[ 'l' ] = 30.
br.form[ 'b' ] = 0.1
br.form[ 'vlsr' ] = 100.

response = br.submit()
print response.read()

I get the following output:

Traceback (most recent call last):
  File "Fill_webform_noname_nonumber.py", line 6, in <module>
    br.select_form(nr=0)
  File "//anaconda/lib/python2.7/site-packages/mechanize/_mechanize.py", line 524, in select_form
    raise FormNotFoundError("no form matching "+description)
mechanize._mechanize.FormNotFoundError: no form matching nr 0

In the other questions, the solution was either to select e.g. the first form if it has no name by:

br.select_form(nr=0)

as I have already tried, or find the available forms by:

print [form for form in br.forms()]

In the latter case, I am simply returned with an empty list.

I'm obviously missing something. How can I submit this form?

Community
  • 1
  • 1
astro_andy
  • 37
  • 10

0 Answers0