在Android中使用Jsoup向表单提交GET

时间:2012-11-21 02:14:59

标签: android http jsoup

我正在尝试“模拟”按钮按下并使用用户名和密码进行表单提交,以使用下面的来源登录网站。我已经尝试过了:

Document con = Jsoup.connect("http://www.twinrinks.com/adulthockey/subs/subs_entry.html")
            .data("subs_data1",autoLogInUsername)
            .data("subs_data2",autoLogInPassword)
            .post();

(autoLogInUsername和autoLogInPassword是String对象)

但这似乎并不想正常工作。我已经在这里阅读了堆栈溢出,我已经尝试了很多建议,但我似乎无法让它工作。我认为我的问题是表单是GET而不是POST,或者我没有使用提交按钮做任何事情(但我不知道如何引用它,因为它没有名称)。谢谢你的帮助!

<html>
<head>
<title>Login Page</title>
<FONT FACE="ARIAL" SIZE="5" color="#FF00FF">Twin Rinks Ice Pavilion, Inc. Attendance & Subs Program<BR></font>
</head>
<body onLoad="document.forms.myform.subs_data1.focus()">
<form name="myform" method="GET" action="subs_entry.php">
Username:<input type=text name=subs_data1 size="70" value="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
(your email address)<br>
Password:<input type=password name=subs_data2 size="25" value=""><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type=submit value="Login!">
<br><br>Leisure next session  
    schedule is done.<br>Bronze next session schedule is done.<br>Silver 
    next session schedule is done<br>Gold 
    next session schedule is done.<br>Platinum next session  
    schedule is done.</form>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

您可以将GET信息直接放在您正在访问的网站的URL中。 POST会更难,但你没有处理。

例如,如果您想将变量x=3y=4发送到foo.com/index.html,则可以直接调用

http://www.foo.com/index.html?x=3&y=4
相关问题