HttpClient post请求拼接数字
来源:互联网 发布:mac dns设置成什么值 编辑:程序博客网 时间:2024/06/05 17:35
private String url="http://japi.juhe.cn/comic/book"; private String key="1e58b105e63d17c29181e6cea32b0279";
private int num=10;
new scall(url,key,num);
public static String scall(String url,String key,int skip){
StringBuffer result=new StringBuffer();
HttpClient httpClient=new DefaultHttpClient();
HttpPost httpPost=new HttpPost(url);
try {
List<NameValuePair> pairs=new ArrayList<>();
pairs.add(new BasicNameValuePair("key",key));
pairs.add(new BasicNameValuePair("skip",skip+""));
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(pairs, "UTF-8");
httpPost.setEntity(entity);
HttpResponse response = httpClient.execute(httpPost);
int code = response.getStatusLine().getStatusCode();
String reson = response.getStatusLine().getReasonPhrase();
if(200==code){
HttpEntity entity1 = response.getEntity();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(entity1.getContent()));
String line=null;
while ((line=bufferedReader.readLine())!=null){
result.append(line);
}
return result.toString();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
阅读全文
0 0
- HttpClient post请求拼接数字
- HttpClient--HttpClient的Post请求
- Httpclient发送POST请求
- httpClient发送post请求
- HttpClient发起post请求
- HttpClient post 请求实例
- HttpClient发起POST请求
- httpclient Post请求
- httpclient post请求
- HttpClient Post请求
- httpclient post/set请求
- HttpClient发送post请求
- httpclient发送post请求
- httpClient post/get请求。
- httpClient post请求设置
- HttpClient get,Post请求
- HttpClient 发送 POST 请求
- HttpClient的post请求
- 头文件中常包含的内容
- 电信盒子HG680-J 1.3.7刷机升级
- RecyclerView实现频道管理
- 加点,无限轮播
- 在java中生成二维码,并直接输出到jsp页面
- HttpClient post请求拼接数字
- Unity 动画系统-Mecanim
- python-callback的理解
- session过期后iframe页面如何跳转到parent页面
- IntelliJ Idea 常用快捷键列表
- python多线程编程:简介-创建-方法-通信
- 更新PAC期初成本
- Go语言并发编程总结
- Linux基础篇之内存管理机制