maurizio de ruggiero
maurizio de ruggiero

Reputation: 63

Python requests fill form of drop down menu

I am trying to fill a form with python requests. Some of the inputs are from a drop down menu like this

<td class="label">Format:</td>
            <td>
                <select id="format" name="format" onchange="Format()">
                    <option>---</option>
                    <option value="MP3">MP3</option>
                    <option value="FLAC">FLAC</option>
                    <option value="AAC">AAC</option>
                    <option value="AC3">AC3</option>
                    <option value="DTS">DTS</option>
                </select>

I usually use mechanize for this but since this is an SSL site I can make it work even with all the tricks found online. My question is: how can i make requests select for example MP3? I know I have to use a dictionary like

data = {'title': 'Hello',  'name' : 'World'} 

And so on.. But how to make it select from a menu??

Upvotes: 0

Views: 2240

Answers (1)

Dekel
Dekel

Reputation: 62536

The name of the select element is format and the value should be one of MP3/FLAC/AAC/AC3/DTS, so you need to use exactly that:

data = {'title': 'Hello',  'name' : 'World', 'format': 'MP3'}

(for example).

Upvotes: 1

Related Questions