HttpClient

利用HttpClient 得到页面内容方法:

HttpClient httpclient = new DefaultHttpClient();

     HttpGet httpget = new HttpGet(“http://www.google.com”);
      HttpResponse response = httpclient.execute(httpget);
         HttpEntity entity = response.getEntity();
         String htmlContent=EntityUtils.toString(entity);

System.out.prinln(htmlContent);  ///这样便得到Google页面Html

更有用的是HttpClient 还提供了模拟浏览器登录。

posted on 2012-10-21 20:32  adolfmc  阅读(326)  评论(0编辑  收藏  举报