2014-02-12 95 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