gpt4 book ai didi

java - http客户端响应

转载 作者:太空宇宙 更新时间:2023-11-04 08:22:57 24 4
gpt4 key购买 nike

我正在尝试自动登录网页。我假设我通过了正确的凭据。

entity.getContentLength() 显示 20,但我看到的响应格式不正确。它不是 HTML。我应该如何进一步进行。下面是我的代码。

String input_text = "https://www.abc.com";
HttpPost httpost = new HttpPost(input_text);

List <NameValuePair> nvps = new ArrayList <NameValuePair>();
nvps.add(new BasicNameValuePair("email", "abc@xyz.com"));
nvps.add(new BasicNameValuePair("passsword", "ttyyeri"));
nvps.add(new BasicNameValuePair("publicLoginToken",""));

httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));

HttpResponse response = httpclient.execute(httpost);
entity = response.getEntity();

if (entity != null) {
BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent()));
String readLine;
while(((readLine = br.readLine()) != null)) {
System.err.println("br :"+readLine);
}
System.out.println("Response content length: " + entity.getContentLength());

}

System.out.println("HTML Content :::"+entity.getContent().toString());

最佳答案

尝试

  StatusLine l = response.getStatusLine();
System.out.println(l.getStatusCode() + " " + l .getReasonPhrase());

输出?

关于java - http客户端响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9184229/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com