我想使用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