Koe*_*sso 5 java forms post httpclient submit
我正在尝试填写 HTML 表单,按下表单的提交按钮,然后从中获取响应。
填写表单非常有效,但我不知道如何按下页面上的提交按钮。
我正在使用 apache httpclient 库。
我的代码是:
httpclient = new DefaultHttpClient();
HttpPost httpost = new HttpPost(pUrl);
List <NameValuePair> nvps = new ArrayList <NameValuePair>();
nvps.add(new BasicNameValuePair("filter_response_time_http", "1"));
nvps.add(new BasicNameValuePair("filter_port", "80"));
nvps.add(new BasicNameValuePair("filter_country", "US"));
nvps.add(new BasicNameValuePair("submit", "Anzeigen"));
httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
response = httpclient.execute(httpost);
entity = response.getEntity();
Run Code Online (Sandbox Code Playgroud)
提交按钮的代码是:
<input onclick="doSubmit();" id="submit" type="submit" value="Anzeigen" name="submit" />
Run Code Online (Sandbox Code Playgroud)