Python Mechanize: how to choose a dropdown when two have the same name on a webpage?

The html I'm trying to execute for Mechanicalize syntax is:

<select id="topic_id2" name="topics[]" title="blabla" tabindex="4" class="createSelect">
here go options

But then right below it, another drop-down menu appears with the following code:

<select id="topic_id3" name="topics[]" title="optional" tabindex="5" class="createSelect">

Now, if that helps at all, I don’t need to select any value from the latter, 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 to select a control based on its id using mechanize.Browser () (preserving all other form syntaxes)?

thank

+5
source share
1 answer

The external documentation is mechanizerather small and contains only a few examples, but the documentation in the code is much more extensive.

, HTMLForm form form.find_control(id="topic_id3") , . , Browser, br.find_control(id="topic_id3")?

+1

All Articles