简体   繁体   中英

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??

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM