Created
July 16, 2017 17:21
-
-
Save rajeebbanstola/941a42d4bd3d6c8be22cf9a23d75298a to your computer and use it in GitHub Desktop.
Reboot Router when internet stops working. P.S.: I only know a animal by the name of Python.
This file contains hidden or 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 | |
from requests.auth import HTTPBasicAuth | |
import httplib | |
def have_internet(): | |
conn = httplib.HTTPConnection("www.google.com", timeout=5) | |
try: | |
conn.request("HEAD", "/") | |
conn.close() | |
return True | |
except: | |
conn.close() | |
return False | |
if have_internet() : | |
print "Internet is working" | |
else: | |
session = requests.Session() | |
login_data={'username':'admin','password':'admin12345','submit.htm?login.htm':'Send'} | |
session.post('http://192.168.10.1/login.cgi', data=login_data) | |
reboot_data = {'reboot':'Reboot','submit.htm?reboot.htm':'Send'} | |
reboot = session.post('http://192.168.10.1/form2Reboot.cgi', data=reboot_data) | |
reboot.headers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment