Skip to content Skip to sidebar Skip to footer

Sending Post Parameters With Python Using Mechanize

I want to fill out this form using Python:
<

Solution 1:

You should use find_control instead; you can add a nr keyword to select a specific control if there is ambiguity. In your case, the name and type keywords should do.

Also note that a file control doesn't take a value; use add_file instead and pass in an open file object:

br.form.find_control(name='image', type='file').add_file(
    open('/home/user/Desktop/image.jpg', 'rb'), 'image/jpg', 'image.jpg')

See the documentation on forms in mechanize.

Post a Comment for "Sending Post Parameters With Python Using Mechanize"