while(headItr.hasNext()){
System.out.println(headItr.next().toString());
}
//获取内容实体信息
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
System.out.println(EntityUtils.toString(entity));
}
}
public static void main(String[] args) throws IOException,
URISyntaxException {
HttpClient httpclient = new DefaultHttpClient();
//设置URI,也可以在Get的Parameters中设置
URI uri = URIUtils.createURI("http", "vip.showji.com/", -1,
"locating/", "m=手机号&outfmt=json", null);
HttpResponse response = httpclient.execute(httpGet);
//获取响应头信息
String headString = null;
HeaderIterator headItr = response.headerIterator(null);
while(headItr.hasNext()){
System.out.println(headItr.next().toString());
}
//获取内容实体信息
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
System.out.println(EntityUtils.toString(entity));
}
}
}
写的时候,发现真的是不清不楚,太丢人,权当开了个理解的口子吧。这个是从 hao123 网站上找的链接,然后把表单需要的数据找出来用的,不保证一直有效。里面的手机号换成自己的啊。
摘自 w7849516230的专栏