如何使用自动脚本将输入传递到php网页,即我只想知道如何使用脚本将参数传递给文本字段.比如将输入传递到网页的用户名和密码字段,然后按提交按钮(也用脚本).
有利的语言:JAVA
试试Selenium.Selenium非常适合自动化Web浏览器.
也有Java的纯粹支持.但不仅如此.
谈到自定义方法,请参阅......
String urlParameters = "param1=a¶m2=b¶m3=c";
String request = "http://example.com/index.php";
URL url = new URL(request);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("charset", "utf-8");
connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
connection.setUseCaches (false);
DataOutputStream wr = new DataOutputStream(connection.getOutputStream ());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
connection.disconnect();
Run Code Online (Sandbox Code Playgroud)
source(Java - 通过POST方法轻松发送HTTP参数)
| 归档时间: |
|
| 查看次数: |
33240 次 |
| 最近记录: |