日期:2014-05-20 浏览次数:20716 次
public static void main(String[] args) {
CookieStore cookieStore = new BasicCookieStore();
HttpContext localContext = new BasicHttpContext();
localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
String targetUrl = "http://www.fantizi5.com/";
try {
HttpResponse response = new DefaultHttpClient().execute(new HttpGet(targetUrl), localContext);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
System.out.println(EntityUtils.toString(response.getEntity()));
}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}