HttpClient4.3:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
Java代码:
CloseableHttpClient httpclient = HttpClients.custom().setRetryHandler(new DefaultHttpRequestRetryHandler(0,false)).setProxy(new HttpHost("aaa", 8000)).build();
HttpGet httpget = new HttpGet(url);
CloseableHttpResponse response = httpclient.execute(httpget);
String page = EntityUtils.toString(response.getEntity(),"GBK");//获取页面源码