choosing correct form according to form input's name
<p>I want to submit forms in multiple websites. Usually I can't exactly know the form name or form id, but I know the input name that I want to submit.</p>

<p>Let's say there is a website which has couple of forms inside it. My code should check all of the forms, if one of them has a input value named "birthday" it will submit that form. If multiple forms has it, it will submit them all.</p>

<p>How can I achieve this?</p>

<p>You can basically loop over all forms and skip forms that don't contain the desired input:</p>

<pre><code>for form in br.forms():
    if not form.find_control(name="birthday"):
         continue
    # fill form and submit here
</code></pre>

<p>More about <code>find_control()</code> <a href="http://wwwsearch.sourceforge.net/mechanize/forms.html" rel="nofollow">here</a>.</p>

python mechanize