junrong624
                HttpClient client = new HttpClient(); 
		 GetMethod get=new GetMethod("http://www.baidu.com"); 
		 try {
			client.executeMethod(get);
		} catch (HttpException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		 Cookie[] cookies= client.getState().getCookies();
		 if (cookies.length == 0) {  //如果获取cookies为空
	         System.out.println( "None" );  
	      } else {  
	         for ( int i = 0; i < cookies.length; i++) {  
	        	 System.out.println(cookies.length);
	        	 String a=cookies[i].toString();//获取cookies里面所有信息
	            System.out.println(a);  
	         }  
	      }  

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2021-12-26
  • 2022-12-23
  • 2022-03-08
  • 2021-07-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
  • 2021-12-04
  • 2022-01-07
相关资源
相似解决方案