Skip to content

Instantly share code, notes, and snippets.

@thinkjson
Forked from tcg/comfort_sweet.py
Last active December 11, 2015 22:58
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 thinkjson/4673594 to your computer and use it in GitHub Desktop.
Save thinkjson/4673594 to your computer and use it in GitHub Desktop.
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