【求助】验证码与账号密码同步提交问题
想用python实现自动登陆网站,已经实现自动识别验证码,但现在不知道如何把账号密码同验证码同步提交来登陆系统。现在的流程是先去网站链接下载验证码到本地,然后来识别好传递给函数.verify参数
Brower(url,user,password,verify):
login_page = "http://xx.xx.xx.xx/checkLogin"
try:
cj = cookielib.CookieJar()
print cj
opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders = [('User-agent','Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)')]
data = urllib.urlencode({"username":user,"userpass":password,"verify":verify,"ajax":1,"think_html_token":""})
opener.open(login_page,data)
op=opener.open(url)
data= op.read()
return data
except Exception,e:
print str(e)
print opener
print Brower("http://xx.xx.xx.xx/login","user","pw","verify")
但这样子没法成功,请问如何解决同步post问题,多谢!
附:
1.截取到的cookie:think_template=default; PHPSESSID=p0vd9ha7sr45vrl3nad0m0kv77
2.网页源代码生成验证码的代码:
function fleshVerify(){
//重载验证码
var timenow = new Date().getTime();
$('verifyImg').src= '/index.php/verify/'+timenow;
}
function ToEmpty() {
var elements=document.getElementsByTagName("input");
for(var i in elements){
var element=elements[i];
if((element.type=="text")||(element.type=="password"))element.value="";
}
}