Last active
May 2, 2016 10:49
-
-
Save hansnow/06ce948f83855247a971310539baf9e2 to your computer and use it in GitHub Desktop.
政法ChinaUnicom热点登录脚本
This file contains hidden or 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
#!/usr/bin/env python | |
#-*- coding: utf-8 -*- | |
import requests as rq | |
import re | |
def login(mobile, password, address): | |
s = rq.session() | |
r = s.get('http://202.106.46.37/?basname=W1-BTPZ-M6000') | |
headers = { | |
'Origin': 'http://202.106.46.37', | |
'Referer': 'http://202.106.46.37/?basname=W1-BTPZ-M6000', | |
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36', | |
'Content-Type': 'application/x-www-form-urlencoded' | |
} | |
payload = { | |
'basPushUrl': 'http://202.106.46.37/?basname=W1-BTPZ-M6000', | |
'debugua': '', | |
'testmacauth': 'false' | |
} | |
s.post('http://202.106.46.37/index.do', data=payload, headers=headers) | |
r = s.get('http://202.106.46.37/login.do?callback=jQuery171027017160079112745_1462173469941&username={}&password={}&passwordType=6&wlanuserip=&userOpenAddress={}&checkbox=0&basname=W1-BTPZ-M6000&setUserOnline=&sap=&macAddr=&bandMacAuth=0&isMacAuth=&basPushUrl=http%253A%252F%252F202.106.46.37%252F%253Fbasname%253DW1-BTPZ-M6000&passwordkey=&_=1462173948842'.format(mobile, password, address)) | |
print re.findall(r'"message":"(.*?)"', r.text)[0] | |
def logout(): | |
rq.get('http://202.106.46.37/logout.do') | |
print 'ok' | |
def main(): | |
# ln 代表辽宁 | |
login('13079824114', 'XXXXXX', 'ln') | |
if __name__ == "__main__": main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment