如何从 HttpClient HttpResponse 获取源代码?
这是我的 HttpClient 请求:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.***.**/***/***_***.php");
String HTML = "";
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("from", contactName));
nameValuePairs.add(new BasicNameValuePair("msg", message));
nameValuePairs.add(new BasicNameValuePair("sent", time_sent));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HTML = "How?";
} catch (ClientProtocolException e) {} catch (IOException e) {}
如何使用请求的源代码填充 HTML 字符串?
Here is my HttpClient request:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.***.**/***/***_***.php");
String HTML = "";
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("from", contactName));
nameValuePairs.add(new BasicNameValuePair("msg", message));
nameValuePairs.add(new BasicNameValuePair("sent", time_sent));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HTML = "How?";
} catch (ClientProtocolException e) {} catch (IOException e) {}
How can I fill the HTML string with the source code of the request?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
就这样:
There you go:
您可以通过从 httpresponse.getEntity().getContent(); 读取流来获取响应 html
不知何故,我认为这可能无法回答您的问题,因为您使用了“源代码”一词。
You can get the response html by reading the stream from the
httpresponse.getEntity().getContent();
Somehow I think this might not answer your question because you use the word "source code".