我只是想获取解析数据的页面来源。
我使用了以下代码
public static String getPageSourceFromUrl(String Url) {
String text = "";
try {
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(Url);
HttpResponse response = client.execute(request);
InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(
new InputStreamReader(in));
StringBuilder str = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
str.append(line);
}
in.close();
text = str.toString();
} catch (Exception ex) {
}
return text;
}
页面是:“ http://vn.answers.yahoo.com/question/index?qid=20111022210730AAWvfKI ”
不幸的是,在某些页面(如上面的页面)中,文本返回只是整个源代码的一部分。也许字符串超出了限制,所以有人有任何解决方案吗?