该网站的格式如下
<li><a tabIndex=2 target="_blank"
href="/portal/site/login/en-gb/help.html"
class="assistance redArrow">Need help with logging in?</a>
</li>
<li><label for="username">User Name</label> <input tabIndex=3
class="authInput" type="text" id="username" name="username"
autocomplete="off" class="authInput" /></li>
<li><label for="password">Password</label> <input tabIndex=4
type="password" id="password" name="password" autocomplete="off"
class="authInput" /></li>
<li class="persist"><label for="secureComputer"> <input type="checkbox"
value="1" tabIndex="5" name="rememberMe" id="secureComputer"
/><span style="padding-left:10px;">I am on a secure computer.</span>
<br><span style="margin-left: 23px; font-size: 10px;">(Only check if this computer is secure and is only used by you.)</span>
</label></li>
</ol>
<a tabIndex=6
href="/IDM/pwdservice?a=fp"
class="assistance redArrow">Forgotten your Password?</a><br>
<input tabIndex=7 type="submit"
value="Login"
class="redBtn"/><br>
我尝试以与this类似的方式登录。这就是我正在进行的方式
URL server = new URL(url);
HttpsURLConnection urlConn = (HttpsURLConnection) server.openConnection();
urlConn.setRequestMethod("POST");
urlConn.setDoOutput(true);
urlConn.setDoInput(true);
urlConn.setUseCaches(false);
DataOutputStream printout = new DataOutputStream (urlConn.getOutputStream());
if (parameters != null)
printout.writeBytes (parameters);
printout.flush();
printout.close();
其中parameters
的格式为name1=value1&name2=value2.....&username=uname&password=pwd
但问题是我想为登录(tabindex = 7)添加参数名称及其值,如上面提到的链接所示,输入也是如此但我没有只列出它的值?
有没有其他方式提交此类表单登录网站? HTML页面上有loginSubmit
个功能,有没有办法将其用于urlConn
。