【问题标题】:Android jsoup doesnt get complete HTML documentAndroid jsoup 没有得到完整的 HTML 文档
【发布时间】:2013-03-10 17:56:26
【问题描述】:

我的 jsoup 库有问题,当我使用 post 方法请求 URL 时,我无法下载完整的 HTML 文档,我只得到了一半的文档。 我该如何解决这个问题。 提前致谢。

Thread hilo = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            String url = "http://correos.es/comun/CodigosPostales/1010_s-CodPostal.asp";
                            Map<String, String> mapa = new HashMap<String, String>();
                            mapa.put("LlamarWebService", "false");
                            mapa.put("Prueba", "");
                            mapa.put("Ejecutando", "Direcciones");
                            mapa.put("Formu1", "FormLoc");
                            mapa.put("Formu2", "FormProvin");
                            mapa.put("CodPostal", numero);

                            String userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.60 Safari/537.17";
                            Connection conn = Jsoup.connect(url).data(mapa).userAgent(userAgent);
                            Document doc = conn.post();
                            Elements elemento = doc.select("div.txtNormal");
                            Log.e("", elemento.toString());

                        } catch (Exception e) {
                            Log.e("Error", e.toString());
                        }
                    }
                });
                hilo.start();

【问题讨论】:

    标签: android jsoup document


    【解决方案1】:

    您是否在 Eclipse Logcat 中编写 html 代码?您可能只看到文本的一部分,因为 Eclipse 限制了显示文本的长度。 This post 可能会对你有所帮助。

    戈达克

    【讨论】:

    • Logcat 仅用于测试,但选择的文档为空。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-23
    • 1970-01-01
    相关资源
    最近更新 更多