我想使用 HTTP GET 和 POST 命令从网站检索 URL 并解析 HTML。我该怎么做?
最佳答案
您可以使用 HttpURLConnection结合URL .
URL url = new URL("http://example.com");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
InputStream stream = connection.getInputStream();
// read the contents using an InputStreamReader
关于java - 如何使用 Java 从网站检索 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/359439/