我想向应该以 .csv 文件响应的 HTTPS 站点发出发布请求。我有这个 Python 代码:
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 扩展(高级 Rest 客户端,这正在工作......)的 POST 请求