AUTOSCRIPTS WITH PYTHON

AutoScripts With Python


I need to log on campus network automatically because there’s a automatic disconnection everyday. First I choose AutoHotKey to write a script but it is incredibly inflexible, then I choose requests in python to get there.

install requests

# assume that you have python already
pip install requests

new a script named fdu_network.pyw

import requests

def login():
    data={'username':'xxxxxxxx','password':'{TEXT}xxxxxxxx','n':100,'type':1,'drop':0}
    r = requests.post("http://10.108.255.249/cgi-bin/do_login", data=data)
    print(r.text)

if __name__ == '__main__':
    login()

Note that, use a .pyw suffix to avoid the black window when running.

Then add it to windows task scheduler.

REFERENCE


  1. win7计划任务设置方法
  2. win计划任务屏蔽python弹窗
Chen Zhigao wechat
CONTACT ME!