私はHTMLフォームに記入しようとしていますが、フォームの送信ボタンを押してから応答を取得しようとしています。Javaで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();
submitボタンのコードは次のとおりです。
<input onclick="doSubmit();" id="submit" type="submit" value="Anzeigen" name="submit" />
'UrlEncodedFormEntity'の2番目のパラメータは、' HTTP.UTF_8'が推奨されていないため、 'java.nio.charset.StandardCharsets.UTF_8'にする必要があります。 – 0x6B6F77616C74