我正嘗試使用Python登錄到網站。我編寫了代碼連接到目標,但我需要登錄並選擇網站上的按鈕並等待響應。我已經看過Python中的HTTP協議,並且正在考慮使用'HTTPConnection.putrequest'。我不知道如何做到這一點,我有我到目前爲止下面的代碼:登錄網站並使用Python選擇選項
def testHTTPS(self):
c = httplib.HTTPSConnection(ip)
c.request("GET", "/")
response = c.getresponse()
self.assertEqual(response.status, 200) # '200' is success code
conn.close()
而對於網站上的登錄功能的代碼是:
<td align="right" id="lgn_userName"></td>
<td><input type="text" class="button" name="username" id="username" size="24" maxlength="16" accesskey="u" tabindex="1" value=""/></td>
</tr>
<tr>
<td align="right" id="lgn_userPwd"></td>
<td><input type="password" class="button" name="password" id="password" size="24" maxlength="20" accesskey="p" tabindex="2" value=""/></td>
</tr>
<tr>
<td align="right"> </td>
<td>
<input type="submit" id="lgn_button" class="button" tabindex="3" accesskey="s" />
</td>
有誰知道如何去做這個?
感謝