public static String getBody(String url) throws Exception{
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
httpGet.addHeader("Cookie", "");
httpGet.addHeader("User-Agent", "");
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity entity=httpResponse.getEntity();
String jsonStr = EntityUtils.toString(entity, "utf-8");
if(httpResponse.getStatusLine().getStatusCode() == 200){
return jsonStr;
}
return "";
}
模拟GET请求
最新推荐文章于 2024-07-17 15:11:26 发布