似乎是一个错误。我已经使用 jsoup 1.6.3 版本尝试了您所说的内容,但执行被卡在Document doc = DataUtil.parseByteData(byteData, charset, url.toExternalForm(), req.parser());
了org.jsoup.helper.HttpConnection
.
您可以使用以下代码验证是否正在建立连接:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import org.jsoup.Jsoup;
public class JSoupTest
{
public static void main(String[] args) throws Exception
{
URL url = new URL("http://www.cisg.law.pace.edu/cisg/biblio/full-biblio.html");
//int timeout = 20 * 1000;
System.out.println("Start parsing...");
//Jsoup.parse(url, timeout);
URLConnection con = url.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
String line = null;
while(true)
{
line = reader.readLine();
if(line == null)
break;
System.out.println(line);
}
System.out.println("Done");
}
}