表单机器人提交多个javascript表单

时间:2022-09-25 16:25:51

I have multiple form named from "form1" to "form5" within a same root url, for example 222.111.111.100/Form/. In the first page, which means

我在同一个根URL中有多个从“form1”到“form5”的表单,例如222.111.111.100/Form/。在第一页,这意味着

http://222.111.111.100/Form/B.do?a=first

The form in the response http request would be writtin in a general style as following:

响应http请求中的表单将以一般样式写入,如下所示:

<form name="form1" action="B.do?a=first" method="post"  > 
<input name="sure" type="checkbox" id="sure" value="" /> 
<input name="submit" type="submit" value="NextStep" /> 
</form>

I need to fill the form automatically one by one as the previous form will have impact on the next one. And to be clear, after this form1, the url will trace to:

我需要逐个填写表单,因为前一个表单会对下一个表单产生影响。并且要明确,在此form1之后,url将跟踪到:

http://222.111.111.100/Form/B.do?a=second

The problem is when I using cUrl to get the content, then javascript dealing with the input checkbox or submit/nextstep button, the document.forms[0].submit() for each form does not working. Even if i passed to the second page, it seems that the Global Variable have not been passed to the next page.

问题是当我使用cUrl获取内容,然后javascript处理输入复选框或submit / nextstep按钮时,每个表单的document.forms [0] .submit()都不起作用。即使我传递到第二页,似乎全局变量尚未传递到下一页。

2 个解决方案

#1


There are many ways to solve your problem, i sugest you to learn about Selenium. Selenium allows you to automate browsers, it is mainly used for automating web applications for testing purposes.

有很多方法可以解决您的问题,我很高兴您了解Selenium。 Selenium允许您自动化浏览器,它主要用于自动化Web应用程序以进行测试。

Otherwise it would be completely recreate JavaScript calls, but this would not allow use JavaScript itself as apparently you desire.

否则它将完全重新创建JavaScript调用,但这不允许使用JavaScript本身,因为显然你想要。

Selenium: http://www.seleniumhq.org/

#2


Not sure I understand your situation correctly, but I will say it: Javascript is client side only, so if you change page or reload, the variables available to your js code will get back to their initial value.

我不确定我是否理解你的情况,但我会说:Javascript只是客户端,所以如果你改变页面或重新加载,你的js代码可用的变量将恢复到它们的初始值。

So if you have control on the server side, you can make the page B.do?a=first return (for example) a json data string which your js may use to fill the next form.

因此,如果您在服务器端具有控制权,则可以使页面B.do?a = first返回(例如)json数据字符串,您的js可用于填充下一个表单。

#1


There are many ways to solve your problem, i sugest you to learn about Selenium. Selenium allows you to automate browsers, it is mainly used for automating web applications for testing purposes.

有很多方法可以解决您的问题,我很高兴您了解Selenium。 Selenium允许您自动化浏览器,它主要用于自动化Web应用程序以进行测试。

Otherwise it would be completely recreate JavaScript calls, but this would not allow use JavaScript itself as apparently you desire.

否则它将完全重新创建JavaScript调用,但这不允许使用JavaScript本身,因为显然你想要。

Selenium: http://www.seleniumhq.org/

#2


Not sure I understand your situation correctly, but I will say it: Javascript is client side only, so if you change page or reload, the variables available to your js code will get back to their initial value.

我不确定我是否理解你的情况,但我会说:Javascript只是客户端,所以如果你改变页面或重新加载,你的js代码可用的变量将恢复到它们的初始值。

So if you have control on the server side, you can make the page B.do?a=first return (for example) a json data string which your js may use to fill the next form.

因此,如果您在服务器端具有控制权,则可以使页面B.do?a = first返回(例如)json数据字符串,您的js可用于填充下一个表单。