HttpGet hg = new HttpGet(url);
List<Header> headers = new ArrayList<Header>();
headers.add(new BasicHeader("Accept-Charset","utf-8"));
headers.add(new BasicHeader("User-Agent", "HorseRaceAnalyzer"));
RequestConfig config = RequestConfig.custom().setRedirectsEnabled(false).build();
HttpClient hc = HttpClientBuilder.create()
.setDefaultRequestConfig(config)
.setDefaultHeaders(headers).build();
HttpResponse hr = hc.execute(hg);
int status = hr.getStatusLine().getStatusCode();
if (status != HttpStatus.SC_OK) {
return null;
}
return EntityUtils.toString(hr.getEntity(), "UTF-8");
0 件のコメント:
コメントを投稿