我有一个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();
答案 0 :(得分:0)
您是否在Eclipse Logcat中编写了html代码?您可能只看到文本的一部分,因为Eclipse限制了所显示文本的长度。 This post可能会对您有所帮助。
Gordak