Initial commit
This commit is contained in:
commit
a30cc63da3
6
requirements.txt
Normal file
6
requirements.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
certifi==2019.3.9
|
||||
chardet==3.0.4
|
||||
idna==2.8
|
||||
pkg-resources==0.0.0
|
||||
requests==2.21.0
|
||||
urllib3==1.24.2
|
35
thaiwifi.py
Normal file
35
thaiwifi.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
import logging
|
||||
logging.basicConfig(
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||||
level=logging.INFO)
|
||||
|
||||
import os
|
||||
import requests
|
||||
import time
|
||||
|
||||
COUNT = 5
|
||||
TIMEOUT = 1
|
||||
INTERVAL = 0.2
|
||||
HOST = '192.168.50.1'
|
||||
PING_COMMAND = 'ping -c {} -W {} -i {} {} > /dev/null 2>&1'
|
||||
|
||||
LOGIN_URL = 'http://login.tulip.biz/portal/user-authen.php'
|
||||
LOGIN = dict(txtLogin='tb215', txtPasswd='363499')
|
||||
LOGIN_TIMEOUT = 10
|
||||
|
||||
while True:
|
||||
try:
|
||||
connected = not os.system(PING_COMMAND.format(COUNT, TIMEOUT, INTERVAL, HOST))
|
||||
|
||||
if not connected:
|
||||
requests.post(LOGIN_URL, data=LOGIN, timeout=LOGIN_TIMEOUT)
|
||||
logging.info('Attempted to login.')
|
||||
time.sleep(10)
|
||||
|
||||
time.sleep(0.5)
|
||||
except KeyboardInterrupt:
|
||||
logging.info('Exiting...')
|
||||
break
|
||||
except BaseException as e:
|
||||
logging.error(str(e))
|
||||
time.sleep(10)
|
9
thaiwifi.sh
Normal file
9
thaiwifi.sh
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
##################
|
||||
# Old cron script
|
||||
##################
|
||||
|
||||
if curl http://t0.vc/f/wifi-test.txt | grep -q 'Please wait while you are redirected'; then
|
||||
curl 'http://login.tulip.biz/portal/user-authen.php' --data 'txtLogin=tb215&txtPasswd=363499&btnLogin=Login&reqUrl=http%3A%2F%2Fgoo.gl%2Fe4wv&reqCheck=false'
|
||||
fi
|
Loading…
Reference in New Issue
Block a user