2

我尝试在网站上发布广告。
我们有 2 个表单,第一个表单询问我的广告信息,我可以提交它们,但在第二个表单中,我有一个带有 javacript 的按钮(输入),

onclick="action_cmd('delete')"

我使用 mechanize 和 python 。

代码javascript是:

function action_cmd(action){
var hidden = document.getElementById("div_cmd");
hidden.innerHTML += "<>input type=\"hidden\" name=\"cmd\" value=\"" + action + "\">";
document.form_ads_action.submit();
}

代码 python :
对于第一种形式,我添加了信息。

br.open("link")
br.select_form(nr=0)
br.submit()

首先可以。

对于第二种形式:

br.select_form(nr=0)
br.submit()

不起作用。

代码HTML:

form name="ads_action" action="link" method="post" enctype="multipart/form-data">
input type="image" name="back" id="back" value="Back"   onClick="action_cmd('back');">
input type="image" name="continue" id="continue" value="Val"onClick="action_cmd('delete')">

请帮助我

4

1 回答 1

1

You have the same form number:

br.select_form(nr=0)
br.submit()

If it's different form on the same page, then it should be:

br.select_form(nr=1)
br.submit()

Or if you want to specifically select the second form, you can do that by name:

br.select_form(name = "ads_action")
br.submit()
于 2013-04-11T08:19:58.917 回答