1
的Python我想用填写此表的Python:发送POST参数,使用机械化
<form method="post" enctype="multipart/form-data" id="uploadimage">
<input type="file" name="image" id="image" />
<input type="submit" name="button" id="button" value="Upload File" class="inputbuttons" />
<input name="newimage" type="hidden" id="image" value="1" />
<input name="path" type="hidden" id="imagepath" value="/var/www/httpdocs/images/" />
</form>
正如你所看到的,也有被命名完全一样的两个参数,所以,当我使用机械化要做到这一点,是什么样子的:
import mechanize
br = mechanize.Browser()
br.open('www.site.tld/upload.php')
br.select_form(nr=0)
br.form['image'] = '/home/user/Desktop/image.jpg'
br.submit()
我收到错误:
mechanize._form.AmbiguityError: more than one control matching name 'image'
每S我在互联网(包括本网站)找到的解决方案没有奏效。有不同的方法吗? 重命名HTML表单中的输入可能不是一个选项。
在此先感谢。
你知道有两个具有相同ID的元素是__illegal__ HTML吗? – orlp