0

当向 http://blahblahblah.com/site/Login/?domain=blahblahblah.com&request=[request string] 发送 GET 请求时,服务器总是响应 413 错误。在浏览器中,此请求显示带有 javascript 重定向的 html 页面。但是在 Jsoup 中获取这个 URL 的时候会抛出异常。我认为这是为了防止自动登录。我想得到响应的 html 宽度 Jsoup。

try{
Response response = Jsoup.connect("http://blahblahblah.com/site/Login/?domain=blahblahblah.com&request=abc123").method(Method.GET).execute();
}
catch (HttpStatusException e) {
//? What i must write here to get response
}

在 C#/.Net HttpWebRequest 异常对象中包含响应,我可以从中提取 html 数据。如何在java / android中做到这一点?

对不起我的英语不好。

4

1 回答 1

0

您可以使用:

try{
        Connection response = Jsoup.connect("http://blahblahblah.com/site/Login/?domain=blahblahblah.com&request=abc123").method(Method.GET);
        response.ignoreHttpErrors(false);
        org.jsoup.Connection.Response r = response.execute();
    }
        catch (HttpStatusException e) {
//not throwed
    }
于 2013-11-13T20:55:37.660 回答