python mechanize FormNotFoundError
Question: I am working on mechanize to fetch form element

    
    
    import mechanize
    br = mechanize.Browser()
    br.set_handle_robots(False)
    br.open("http://www.bnm.gov.my/index.php?ch=12&pg=622")
    br.select_form(name="Rates")
    

But this is throwing error:

    
    
    FormNotFoundError: no form matching name 'Rates'
    

Even though there is

    
    
    <form onsubmit="return validate();" method="get" action="index.php" name="Rates">
    

can some one help on this

Thanks in advance


Answer: Try selecting the form with the nr param:

    
    
    select_form(self, name=None, predicate=None, nr=None)
    

I guess that page has only 1 form, so try nr=0.

If there is no form in the page, then it probably means that it was added
using Javascript. And, in that case, mechanize won't be enough. You will have
to use Selenium or Spynner.

