【问题标题】:Why do I get only a half of html source code?为什么我只得到一半的 html 源代码?
【发布时间】:2013-01-22 15:51:20
【问题描述】:

在我的 android 应用程序中,我使用 asynctask 从网站获取 html 源代码。 为此,我使用 HttpURLConnection :

protected Void doInBackground(Void... v) {
    try {
        URL url = new URL("http://xx.com/test.pl");
        HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
        InputStream inputStream = httpURLConnection.getInputStream();

        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));

        String temp;
        while ((temp = bufferedReader.readLine()) != null) {
            //Pattern pattern = Pattern.compile("&sid=(.*?)\"");
            //Matcher match = pattern.matcher(temp);

            System.out.println(temp);

            Log.e("temp_HoleKunde", temp);
        }
    }
    catch(Exception exe) {
        exe.printStackTrace();
    }
    return null;
}

我在解析网站时总是使用它,它总是运行得非常好。 但现在我有一个非常严重的问题。我登录 logcat 的源代码不是完整的源代码。只有一半显示......或更多,有时更少。 如何在浏览器上获取完整的源代码?

【问题讨论】:

    标签: android html android-asynctask httpurlconnection


    【解决方案1】:

    日志并不意味着打印出数千行代码。我敢肯定,一旦您将其设置为TextView,它将显示整个源代码。

    【讨论】:

    • @StefanM。当您不尝试将它用于从未设计过的目的时,它非常有用。如果 logcat 接受任意大量的文本,您是否考虑过设计影响? Logcat 不用于显示输出。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-14
    • 1970-01-01
    • 1970-01-01
    • 2011-07-13
    相关资源
    最近更新 更多