我想向一個HTTPS站點發出一個POST請求,該站點應該以.csv文件響應。我有這樣的Python代碼:HTTPS POST請求Python,返回.csv
try:
#conn = httplib.HTTPSConnection(host="www.site.com", port=443)
=>給出一個BadStatusLine:'錯誤
conn = httplib.HTTPConnection("www.site.com");
params = urllib.urlencode({'val1':'123','val2':'abc','val3':'1b3'})
conn.request("POST", "/nps/servlet/exportdatadownload", params)
content = conn.getresponse()
print content.reason, content.status
print content.read()
conn.close()
except:
import sys
print sys.exc_info()[:2]
輸出:
Found 302
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>302 Found</TITLE>
</HEAD><BODY>
<H1>Found</H1>
The document has moved <A HREF="https://www.site.com/nps/servlet/exportdatadownload">here</A>.<P>
<HR>
<ADDRESS>Oracle-Application-Server-10g/10.1.3.5.0 Oracle-HTTP-Server Server at mp-www1.mrco.be Port 7778</ADDRESS>
</BODY></HTML>
我在做什麼錯?我如何「抓住」返回的.csv文件? 我嘗試了Chrome瀏覽器擴展(高級休息客戶端,這是工作...)的POST請求
正如錯誤所示,Web服務器希望您通過https訪問url - 當您嘗試建立HTTPSConnection時,確切的錯誤是什麼? – 2013-02-24 23:25:48
在命令行上,以下命令給你什麼? 'curl -XPOST'https://www.site.com/nps/servlet/exportdatadownload?val1 = 123&val2 = abc&val3 = 1b3'' – Trevor 2013-02-24 23:25:53
@ Ali-AkberSaifee:'(,BadStatusLine(「 ''「,))' –
francisMi
2013-02-25 11:40:12