2014-02-12 92 views
0

我的目标是获得我的家政银行进行费用控制。问题是我总是得到一个代码302,也许是因为我发送了一个坏的用户和密钥。以下是发送ssl头文件的正确方法吗?如何访问家庭银行?与邮政和httplib

import httplib 

host = 'www.bancoprovincia.bancainternet.com.ar' 
conn = httplib.HTTPSConnection(host) 
conn.set_debuglevel(1) 
conn.putrequest("POST", "/eBanking/login") 
header = {'accept-Language': 'es-ES,es;q=0.8,en;q=0.6', 
'accept-Encoding': 'gzip,deflate,sdch', 'content-Type': 
'application/x-www-form-urlencoded', 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36'} 

for k, v in header.iteritems(): 
    conn.putheader(k, v) 

user = '##' 
passwd = '##' 
conn.endheaders() 
conn.send('usuario:'+user+'clave:'+passwd) 
res = conn.getresponse() 

print res.status 
print res.getheaders() 

下面是从服务器

send: 'POST /eBanking/login HTTP/1.1\r\nHost: www.bancoprovincia.bancainternet.com.ar\r\nAccept-Encoding: identity\r\ncontent-Type: application/x-www-form-urlencoded\r\naccept-Language: es-ES,es;q=0.8,en;q=0.6\r\naccept-Encoding: gzip,deflate,sdch\r\naccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\nuser-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36\r\n\r\n' 
send: 'usuario:##:clave##' 
reply: 'HTTP/1.1 302 Movido tempor\xe1lmente\r\n' 
header: Date: Wed, 12 Feb 2014 19:40:18 GMT 
header: Server: Apache/2.2.17 (Red Hat Enterprise Web Server) 
header: Set-Cookie: JSESSIONID=696BA6EB7C85B74476817A42C211ED29.tcc1; Path=/eBanking; Secure 
header: Location: https://www.bancoprovincia.bancainternet.com.ar/eBanking/login/inicio.htm;jsessionid=696BA6EB7C85B74476817A42C211ED29.tcc1?login_error=1 
header: Content-Length: 0 
header: Connection: close 
header: Content-Type: text/plain; charset=UTF-8 
302 
+0

格拉西亚斯POR LA edicion,我的英语语法缺少 – lmokto

回答

0

响应查看在响应中的位置标头? 服务器告诉你,你应该使用URI 欲了解更多信息,请参阅http status codes

+0

我理解的301点,但总会留下301,为什么我要问,如果用户的运输和关键是好还是坏。 – lmokto

+0

用户名输入的名称是“j_username”,密码控件的名称是“j_password”。也许尝试更改这些控件的名称 – Alvaro

+0

另外,我强烈建议使用请求模块,它非常易于使用 – Alvaro