-
-
Save thinkjson/4673594 to your computer and use it in GitHub Desktop.
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 # `pip install requests`; DO IT! | |
import time | |
import sys | |
class ComfortSweet: | |
LAST_ATTEMPT = 0 | |
def main(self): | |
self.LAST_ATTEMPT = time.time() | |
expected_form_data = { | |
'username': 'hotelguest', # Checkbox | |
'password': 'wireless', # Hidden | |
'original_url': 'http://www.gstatic.com/generate_204', # Hidden | |
'login': 'Accept', # Named Submit button | |
} | |
result = requests.get( | |
"http://www.icanhaztimestamp.com/", allow_redirects=False) | |
if result.status_code != 200: | |
requests.post( | |
'http://wireless.colubris.com:1080/goform/HtmlLoginRequest', | |
data=expected_form_data) | |
print "\nPosted the goods. Welcome back to the internet." | |
# Be nice. | |
sys.stdout.write(".") | |
time.sleep(5) | |
sys.stdout.flush() | |
if __name__ == '__main__': | |
CS = ComfortSweet() | |
while True: | |
try: | |
CS.main() | |
except KeyboardInterrupt: | |
sys.exit() | |
except requests.exceptions.RequestException as e: | |
print e.__class__.__name__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment