httpclient怎样获取浏览器中某个网站的所有cookie

关键词 发布于 2013/05/08 13:21
阅读 5K+
收藏 1
public static void main(String[] args) throws Exception{

DefaultHttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
CookieStore cookies = new BasicCookieStore();

localContext.setAttribute(ClientContext.COOKIE_STORE,cookies);

HttpGet httpGet = new HttpGet(" http://tieba.baidu.com/f?kw=java&from=prin");
HttpResponse response = httpClient.execute(httpGet,localContext);

System.out.println(response.getStatusLine());
List<Cookie> cookieList = cookies.getCookies();
for(int i = 0 ; i < cookieList.size() ; i++){
System.out.println(cookieList.get(i).toString());
}

httpClient.getConnectionManager().shutdown();

}



为什么这样获取的网站cookie不完整,折磨我好几天了,,,

加载中
0
bosscheng
bosscheng
缺少引入的包,无法回显楼主的结果。
关键词
关键词
引入包的图片已经上传
返回顶部
顶部