Skip to content

Instantly share code, notes, and snippets.

@vivekagr
Created June 3, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vivekagr/25e5cde71a662e5e39ca to your computer and use it in GitHub Desktop.
Save vivekagr/25e5cde71a662e5e39ca to your computer and use it in GitHub Desktop.
alliance re-connect script
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