返回信息流http://gwself.bupt.edu.cn/nav_login
RT,想做一个自动查询剩余流量和余额的脚本,结果卡壳了一下午!!
球大神救助
附上我的代码
import requests
import md5
import re
Target1='http://gwself.bupt.edu.cn/nav_login'
Target2 = 'http://gwself.bupt.edu.cn/LoginAction.action'
username=''
password=''
m1 = md5.new()
m1.update(password)
s = requests.session()
r = s.get('http://gwself.bupt.edu.cn')
#1 connect
r = s.get(Target1)
print r.text
#find checkcode
pattern = re.compile(r'(?<=checkcode=\")\d+')
match = re.search(pattern, r.text)
if match:
checkcode = match.group()
#2 connect
Data={'account':username,'password':m1.hexdigest(),'code':'','checkcode':checkcode,'Submit':'登 录'}
r = s.post(Target2,Data)
print match.group()
print "###################################################################################################################"
print r.text
这是一条镜像帖。来源:北邮人论坛 / python / #8244同步于 2015/8/21
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Python机器人发帖
网关自助服务系统模拟登陆不上
h497018787
2015/8/21镜像同步13 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
贴个我的。。可以查询余额还能强制退出。
url_login = 'http://gw.bupt.edu.cn/a11.htm'
#old
url_getInfo = 'http://gw.bupt.edu.cn'
#
url_logout= 'http://gw.bupt.edu.cn/F.htm'
headers = {'Accept':'*/*',
'Connection':'keep-alive',
'Content-Type':'application/x-www-form-urlencoded',
'Host':'gw.bupt.edu.cn',
'Origin':'http://gw.bupt.edu.cn',
'Referer':url_login,
'User-Agent':'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.8 (KHTML, like Gecko) Chrome/23.0.1251.2 Safari/537.8'
}
headers2= {'Host': '10.8.128.1',
'Connection': 'keep-alive',
'Content-Length': '50',
'Cache-Control': 'max-age=0',
'Origin': 'http://10.8.128.1',
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Referer': 'http://10.8.128.1/portal/logon.htm',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.8 (KHTML, like Gecko) Chrome/23.0.1251.2 Safari/537.8'
}
def log_in():
global user,password
pid='1'
params = {'DDDDD':user,
'upass':password,
'passplace':None,
'AMKKey':None}
req=urllib2.Request (url_login,urllib.urlencode (params),headers)
a=urllib2.urlopen(req)
d=a.read()
a.close()
if d.find(' successfully ')!=-1:
print 'log in!'
time.sleep(0.5)
else:
print 'load fail'
def log_out():
req=urllib2.Request (url_logout,headers=headers)
a=urllib2.urlopen(req)
d=a.read()
a.close()
print 'log out!'
time.sleep(0.5)
def log_Info():
a=urllib2.urlopen(url_getInfo)
try:
d=a.read()
pattern=re.compile("flow='(\d+)\s*';")
flows=pattern.findall(d)
flow=eval(flows[0])
#print flow
print '@@@@@'
print '已经使用流量:',str(round(flow*1.0/1024/1024,2))+'G'
print '@@@@@'
except:
print 'get Infor fail'
time.sleep(1.5)
我是指登陆http://gwself.bupt.edu.cn这个
就是自服务的那个页面,网页还隐藏了验证码,提取出来还是不行
【 在 hdz139 的大作中提到: 】
: 贴个我的。。可以查询余额还能强制退出。
: [code=py]
: url_login = 'http://gw.bupt.edu.cn/a11.htm'
: ...................
需要请求一遍验证码
自己抓个包去看看
【 在 h497018787 的大作中提到: 】
: 我是指登陆http://gwself.bupt.edu.cn这个
: 就是自服务的那个页面,网页还隐藏了验证码,提取出来还是不行
:
: 【 在 hdz139 的大作中提到: 】
: : 贴个我的。
: .........
发自「贵邮」