0
代碼HTTP GET請求:如何添加參數和如何獲得字符串? (Java中,HttpClient的4.X)
HttpClient httpclient = new DefaultHttpClient();
CookieStore cookieStore = new BasicCookieStore();
// Create local HTTP context
HttpContext localContext = new BasicHttpContext();
// Bind custom cookie store to the local context
localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
HttpGet first = new HttpGet("http://vk.com");
HttpResponse response = httpclient.execute(first, localContext);
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
int l;
byte[] tmp = new byte[2048];
while ((l = instream.read(tmp)) != -1) {
}
}
如何獲得性反應STRING?
而我需要創建請求POST,添加參數和自動重定向。
謝謝,怎麼crea te POST請求? – Mediator 2011-04-30 16:19:05
如何添加 HttpClient client = new HttpClient(); client.getParams()。setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); ? – Mediator 2011-04-30 17:21:45
嗯,你已經在你的問題...? – 2011-04-30 17:53:03