gpt4 book ai didi

java - timeOut 是做什么的(使用 Jsoup 进行 html 解析)

转载 作者:行者123 更新时间:2023-12-02 02:34:23 32 4
gpt4 key购买 nike

我对此很陌生,我正在编写一个从 Url 解析 html 的程序:

Document doc = Jsoup.connect("http://example.com").timeout(600000).get();

.timeout(600000) 的作用是什么?

最佳答案

Timeout 设置连接的超时时间(换句话说,就是客户端等待服务器响应的最长时间)。方法参数以毫秒为单位。

以下是 jsoup Connection javadoc 的详细信息。

Timeout: Set the request timeouts (connect and read). If a timeout occurs, an IOException will be thrown. The default timeout is 30 seconds (30,000 millis). A timeout of zero is treated as an infinite timeout. Note that a read timeout is not the same as a maximum timeout. As long as the connection is sending bytes at least every timeout seconds (e.g. in the case of an infinite stream of data, or a slow large download), the read timeout will not fire. This can be mitigated by using a maximum download size (see maxBodySize(int)), or interrupting the connecting thread after a max timeout.

关于java - timeOut 是做什么的(使用 Jsoup 进行 html 解析),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46611852/

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