我在网站上有一个不能直接选择的表单(因为它嵌入在 javascript 中)。所以通过机械化浏览器对象选择它是不可能的。我想要做的是创建一个类似的表单并使用浏览器对象提交它。
形式是
<form method="POST" action="Action.php?action=338&n=66&t=mine">
<input id="Mine66" type="hidden" value="22" name="duree">
<button class="boutonsGeneral" value="submit" type="submit" name="travail">
<span class="infoBoutonsGeneral" title="">
Work
<span id="dureeMine66" class="boutonsGeneral_duree boutonsGeneral_dureePlus">22 hours</span>
</button>
</form>
我使用了萤火虫,这里是信息。发布到的 URL 是http://www.renaissancekingdoms.com/Action.php?action=338&n=66&t=mine
Parameters
时间 22
劳累提交
Request Headers From Upload Stream
内容长度:23
内容类型:application/x-www-form-urlencoded
到目前为止,我所做的是我设法登录该站点并执行了以下操作
form = mechanize.HTMLForm('http://www.renaissancekingdoms.com/Action.php?action=338&n=66&t=mine', method='POST')
form.new_control('duree', 'hidden', {
'id' : 'Mine66',
'value' : '22'})
form.fixup()
br.form = form
br.submit()
但这似乎不起作用。有什么想法我哪里出错了吗?