Created
June 3, 2015 14:16
-
-
Save vivekagr/25e5cde71a662e5e39ca to your computer and use it in GitHub Desktop.
alliance re-connect script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
class AllianceBroadband(object): | |
def __init__(self, username, password, login_identification_string, | |
login_page_url='http://10.254.254.116/0/up/'): | |
self.username = username | |
self.password = password | |
self.login_identification_string = login_identification_string | |
self.login_page_url = login_page_url | |
def login(self): | |
payload = { | |
'user': self.username, | |
'pass': self.password, | |
'login': 'Login', | |
} | |
try: | |
requests.post(self.login_page_url, data=payload) | |
except requests.RequestException: | |
pass | |
def logout(self): | |
try: | |
requests.post(self.login_page_url, data={'logout': 'Click here to logout'}) | |
except requests.RequestException: | |
pass | |
def check_if_logged_out_and_reconnect(self): | |
contents = requests.get(self.login_page_url).text | |
if self.login_identification_string not in contents: | |
self.login() | |
if __name__ == '__main__': | |
conn = AllianceBroadband('Username here', 'Password here', "User's Full Name Here") | |
conn.check_if_logged_out_and_reconnect() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment