HttpClient配置代理的方法

原创
2017/08/16 11:17
阅读数 610

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");//获取页面源码

 

展开阅读全文
加载中

作者的其它热门文章

打赏
0
1 收藏
分享
打赏
0 评论
1 收藏
0
分享
返回顶部
顶部