The html that I'm trying to make mechanize parse is:
<select id="topic_id2" name="topics[]" title="blabla" tabindex="4" class="createSelect">
here go options
But then right below it there is another dropdown, with the following code:
<select id="topic_id3" name="topics[]" title="optional" tabindex="5" class="createSelect">
Now if it helps at all, I need not select any value from the latter one, since it is optional.
When I try
br = mechanize.Browser()
br.select_form(name="form")
br["topics[]"] = ["Internet"]
I get:
mechanize._form.AmbiguityError: more than one control matching name 'topics[]'
Is there a way I can select a control based on its id, using mechanize.Browser() (while retaining all the other form syntax)?
Thanks
The external documentation for mechanize
is quite small and contains just a few examples, but the in-code documentation is far more extensive.
Not having tested this, with an HTMLForm
instance called form
you should be able to call form.find_control(id="topic_id3")
and get what you want. I'm not sure how to do this with just a Browser
object, but have you tried br.find_control(id="topic_id3")
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With