私はパースを機械作るしようとしているHTMLは次のとおりです。Python Mechanize:Webページに2つの名前が同じときにドロップダウンリストを選択するにはどうすればよいですか?
<select id="topic_id2" name="topics[]" title="blabla" tabindex="4" class="createSelect">
here go options
しかし、その後、それを右下の次のコードで別のドロップダウン、そこにある:それは全然場合に役立ちます
<select id="topic_id3" name="topics[]" title="optional" tabindex="5" class="createSelect">
は今これはオプションなので、後者の値を選択する必要はありません。
私は
br = mechanize.Browser()
br.select_form(name="form")
br["topics[]"] = ["Internet"]
をしようとすると、私が得る:
mechanize._form.AmbiguityError: more than one control matching name 'topics[]'
は、私は他のすべてを保持したままmechanize.Browserを()(使用して、そのIDに基づいて制御を選択することができます方法はありますフォーム構文)? mechanize
ため
おかげ
フォームのインデックスでコントロールにアクセスできます。この回答を参照してください。http://stackoverflow.com/questions/6482308/differentiating-between-html-form-select-items-with-the-ame-name/ 6483458#6483458 – cerberos
ありがとう、これはうまくいきました。 –
リンクの回答を+1できますか? – cerberos