在我的Android应用程序上,我使用JSOUP来POST数据来模拟登录表单的提交操作(自动登录到WISPR热点) 这是我从POST获得的原始响应:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>connexion</title>
<script type="text/javascript">
window.location = "http://192.168.2.1:3990/logon?username=0325767676@ssowifi.neuf.fr&response=e30ee504ba06fa77502f1b9e8ccbaf8d&uamip=192.168.2.1&userurl=http%3A%2F%2Fwww.sfr.fr%3Bneuf%3Bfr%3B3%3Bhttp%3A%2F%2Fwww.sfr.fr%3B";
</script>
</head>
<body>
</body>
</html>
我将它与登录成功时使用Firebug的桌面浏览器的响应进行了比较,并且它完全相同,当然除了“响应”参数。
正如您所看到的,它在这里使用Javascript进行重定向。 由于JSOUP仅遵循3xx重定向,因此我尝试从响应中解析给定的位置URL,然后在其上执行GET请求
Document doc = Jsoup.connect(parsedRedirectURL).cookies(cookies).get();
但我得到了
Java.net.SocketTimeoutException: failed to connect to /192.168.2.1 (port 3390) after 3000ms
我错过了什么?
答案 0 :(得分:1)
您的window.location
说:3990
和您的例外3390
。这些参数是来自两次调用,所以端口可能已经改变了吗?如果确实使用了正确的端口,请检查。