편의를 위해 자동으로 웹 액세스 인증 페이지에 로그인하는 약간의 파이썬 스크립트를 만들려고합니다 (컴퓨터가 네트워크에서 연결이 끊어 질 때마다 로그인이 나타납니다).Python을 사용하여 간단한 웹 액세스 로그인에 로그인하는 방법은 무엇입니까?
나의 시도는 지금까지 모듈 기계화를 사용하고 있지만,이 내 표준 브라우저에서 사라지는 로그인을 초래하지 않는 실행하고있다 :이 로그인을 얻을 수있는 방법
import mechanize
browser = mechanize.Browser()
browser.addheaders = [("User-agent","Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13")]
browser.open("https://controller.mobile.lan/101/portal/")
browser.select_form(name="logonForm")
browser["login"] = "myUsername"
browser["password"] = "myPasscode"
browser.submit()
print browser.title()
파이썬으로 작업 하시겠습니까? 어딘가에을 제출 데이터를 형성
<form name="logonForm" style="display:none">
<!-- Logon Form -->
<div id="logonForm_subscriptionChoice_top_title_block" class="subtitle">
<span id="logonForm_subscriptionChoice_top_title_text">YOU ALREADY HAVE YOUR LOGIN</span>
</div>
<div id="logonForm_auth_modes_block" style="display:none">
<table class="hoverLink"><tr>
<td>
<div id="logonForm_shibboleth_authentication_button">
<img src="./resources/_images/shibboleth.png" height="30px"><br><span id="logonForm_shibboleth_text">Utilisez vos identifiants institutionnels</span>
</div>
</td>
<td>
<div id="logonForm_standard_authentication_button">
<img src="./resources/_images/ticket.png" height="30px"><br><span id="logonForm_ticket_text">Utilisez un ticket de connexion</span>
</div>
</td>
</tr></table>
</div>
<div id="logonForm_logon_block">
<table>
<tr id="logonForm_logon_block_credentials">
<td class="label">
<span id="logonForm_login_text">LOGIN</span><br><input type="text" name="login" autocomplete="on">
</td>
<td class="label">
<span id="logonForm_password_text">PASSWORD</span><br><input type="password" name="password" autocomplete="on">
</td>
<td>
<button type="submit" id="logonForm_connect_button"><span><img src="./resources/_images/auth_button.png" height="35px"></span></button>
</td>
</tr>
<tr id="logonForm_policy_block">
<!-- Check Box Confirm (Visible status depends on configuration option) --><td colspan="3">
<br><input type="checkbox" name="policy_accept">
<span id="logonForm_policy_text"></span>
</td>
</tr>
</table>
</div>
<br><button type="button" id="logonForm_authentication_form_back_button" style="display:none">Retour</button>
<div id="logonForm_subscriptionChoice_block">
<br><div class="subtitle">
<span id="logonForm_subcribe_bottom_title_text">NOT A LOGIN YET ?</span>
</div>
<br><div id="logonForm_subscriptionChoice_first_double_insert_block">
<table class="hoverLink"><tr>
<td></td>
<td></td>
</tr></table>
</div>
<div id="logonForm_subscriptionChoice_second_double_insert_block">
<table class="hoverLink"><tr>
<td></td>
<td></td>
</tr></table>
</div>
<div id="logonForm_subscriptionChoice_single_insert_block">
<table class="hoverLink"><tr><td></td></tr></table>
</div>
</div>
</form>
도움 주셔서 감사합니다. 그래, 기계화가이 경우 작동하도록 추가 맞춤 코드가 필요하다는 것을 알 수있다 (페이지는 자바 스크립트를 사용한다). 지금은 [Selenium] (http://www.seleniumhq.org/)의 Python 바인딩을 사용하고 있습니다. 이것은 직관적이지만 세련되지 않습니다 (그래픽 작업을하기 위해 Firefox를로드하는 등). – d3pd
GUI가없는 접근법에 대한 업데이트 된 답변을 확인하십시오. –