这个问题有点老了,但是我认为现在已经弃用了,等等DefaultHttpClient,我应该发布我的答案HttpGet。给定URL,此函数应获取并返回HTML。public static String getHtml(String url) throws IOException { // Build and set timeout values for the request. URLConnection connection = (new URL(url)).openConnection(); connection.setConnectTimeout(5000); connection.setReadTimeout(5000); connection.connect(); // Read and store the result line by line then return the entire string. InputStream in = connection.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuilder html = new StringBuilder(); for (String line; (line = reader.readLine()) != null; ) { html.append(line); } in.close(); return html.toString();}