私はウェブページを介してログインする必要があるケーブルインターネットを持っています。毎日8時と12時にそれがリセットされるのは面倒です。私はログインプロセスを自動化するpythonスクリプトを書こうと思っていました。私はこれまで多くのStackOverflowソリューションを読んできましたが、何も機能していませんでした。私は試しましたRequests、Twill、RoboBrowserなど私のローカルインターネットページにPythonを使用して自動ログイン
私はdoLogin()ajaxスクリプトは、ログインボタンによって起動されました。ここには完全なpage sourceがあります。ソリューション
私はこの問題を解決するためにセレンwebdriverを使用:以下
は
import requests
# Fill in your details here to be posted to the login form.
payload = {
'action': 'http://10.10.0.1/login',
'actualusername': 'username',
'actualpassword': 'password'
}
# Use 'with' to ensure the session context is closed after use.
with requests.Session() as s:
p = s.post("http://103.251.83.134/captiveportal/Default.aspx", data=payload)
# print the html returned or something more intelligent to see if it's a successful login page.
print p.text
# An authorised request.
#r = s.get('http://www.google.com')
#print r.text
も、この答えを読む前に、私はまさに、この今日実装します!これを投稿していただきありがとうございます。私はwebdriver.Firefox()を使用しました。どちらがうまくいくの?私はどこかで読んだように、私はPhantomJSを試してみるために、プロセスが静かであることを望んだ。誰にでも必要な場合は、私はこの受け入れられた解決策を作ります! –