I’m trying to dynamically fill a form in Python using Mechanize. However, when I inspected the source of the HTML page that has the form, I realized that some of the controls on the form have the same name. Here’s an excerpt from the form:
<form action="[some website]" method=post>
<table>
<tr><td>
<select NAME="mv_searchspec" size="1">
<option VALUE="1119">Fall 2011 (1119)</option>
<!-- other options here -->
</select>
</tr><td>
<tr><td>
<select NAME="mv_searchspec" size="1">
<option VALUE="">Select Department</option>
<option VALUE="ACC">ACC</option>
<!-- other options here -->
</select>
</tr></td>
</table>
</form>
Is there a way to get the possible_items of each of the SELECT controls without identifying them by a name/id?
You can use BeautifulSoup to parse the response to get the select options
You can’t do something like
br['mv_searchspec'] = 'foo'as obviously this is ambigious. You should be able to do this though