首页 > 其他 > 详细

crawler_httpclient代理访问

时间:2014-01-25 11:28:46      阅读:358      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
 1 public String getDocumentByProxy(String url)
 2             throws ClientProtocolException, IOException {
 3         DefaultHttpClient httpclient = new DefaultHttpClient();
 4         HttpHost proxy = new HttpHost("127.0.0.1", 8087);
 5         httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
 6                 proxy);
 7         HttpGet httpget = new HttpGet(IllegalCharacter(url));
 8         HttpResponse response = httpclient.execute(new HttpGet(url));
 9         String html;
10         try {
11             html = getContent(response, httpget.getURI().getHost());
12         } finally {
13             httpget.releaseConnection();
14             // 释放连接
15             httpclient.getConnectionManager().shutdown();
16         }
17 
18         return html;
19     }
bubuko.com,布布扣

crawler_httpclient代理访问

原文:http://www.cnblogs.com/cphmvp/p/3532754.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!