String url = "http://www.baidu.com";
try {
HttpHost proxy = new HttpHost("自己的代理Ip",代理的端口号,"http");
HttpHost target = new HttpHost("www.baidu.mn",80,"http");
CredentialsProvider provider = new BasicCredentialsProvider();
provider.setCredentials(new AuthScope(proxy), new UsernamePasswordCredentials("代理用户名", "代理密码"));
CloseableHttpClient httpClient = HttpClients.custom().setDefaultCredentialsProvider(provider).build();
RequestConfig requestConfig = RequestConfig.custom().setProxy(proxy).build();
HttpGet get = new HttpGet(url);
get.setConfig(requestConfig);
CloseableHttpResponse res = httpClient.execute(target,get);
int statusCode = res.getStatusLine().getStatusCode();
String result = EntityUtils.toString(res.getEntity());
} catch (ClientProtocolException e) {
LOGGER.info("异常"+e);
} catch (IOException e) {
LOGGER.info("异常"+e);
}