如何获取URL的HTML内容?

时间:2012-07-09 06:39:29

标签: android android-xml

DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse((new URL(myUrl)).openStream());

我对此感到异常......

1 个答案:

答案 0 :(得分:0)

你可以尝试:

....
URL url = new URL(myURL);
URLConnection connection = url.openConnection();
connection.connect();
InputStream input = connection.getInputStream();
Document doc = docBuilder.parse(input);

URLConnection getContent() return null启发