gpt4 book ai didi

java - 使用 HTTPClient 下载数据

转载 作者:行者123 更新时间:2023-11-30 05:21:41 25 4
gpt4 key购买 nike

有一个关于使用 Apache HTTPClient 的问题。我需要从网站提取数据并发现这个有用的教程 https://hc.apache.org/httpclient-3.x/tutorial.html

在教程中,它说我们将编写一个“下载页面”的简单应用程序。

它到底将页面“下载”到哪里?我没有看到提到建立数据库或某些云存储或诸如此类的信息,那么信息到底“去”哪里(或者一旦提取数据,它保存在哪里)?我对 Java 有点陌生,所以这有点概念性

最佳答案

“下载”转到System.out:

  // Read the response body.
byte[] responseBody = method.getResponseBody();

// Deal with the response.
// Use caution: ensure correct character encoding and is not binary data
System.out.println(new String(responseBody));

关于java - 使用 HTTPClient 下载数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59466861/

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