Skip to content

Instantly share code, notes, and snippets.

@ihciah
Created July 20, 2018 08:25
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 ihciah/305ae130c352d81480de27549d441ec7 to your computer and use it in GitHub Desktop.
Save ihciah/305ae130c352d81480de27549d441ec7 to your computer and use it in GitHub Desktop.
Fudan Keep Online
# -*- coding: utf-8 -*-
import requests
import time
def login():
username = ""
password = ""
url = "http://10.108.255.249/include/auth_action.php"
data = {"username": username,
"password": password,
"action": "login",
"ajax": 1,
"save_me": 1,
"ac_id": 1
}
requests.post(url, data, timeout=2)
def check():
test_content = requests.get("http://t.cn", timeout=2)
return "wlrz.fudan.edu.cn" in test_content.text
def force_func(f):
while True:
try:
return f()
except:
pass
def check_then_login():
is_need = force_func(check)
if is_need:
login()
def keep_me_online():
while True:
force_func(check_then_login)
time.sleep(5)
if __name__ == "__main__":
keep_me_online()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment