使用python请求的post方法无法获得正确的响应

2024-07-03 06:55:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试从this website自动恢复数据(我想要的是“ BVBG.086.01价格报告”)。通过firefox检查,我发现POST所指向的请求URL是“http://www.bmf.com.br/arquivos1/lum-download_ipn.asp”,参数是:

hdnStatus: "ativo"
chkArquivoDownload_ativo    "28"
txtDataDownload_ativo   "09/02/2018"
imgSubmeter "Download"
txtDataDownload_externo_ativo   [3]
    0   "25/08/2017"
    1   "25/08/2017"
    2   "25/08/2017"

所以,如果我用扔吧为了发出请求,响应是正确的302重定向(指向请求文件所在的FTP URL,类似于“Location:/FTP/Temp/10981738”/下载.ex_"). (Example of the request here)。在

所以我尝试用下面的代码做同样的事情(使用python的库“requests”,我尝试了request_body的两个版本,试图将其放入post方法的“data”参数中)

^{pr2}$

我得到的回答是:

<html><head><title>Object moved</title></head>
<body><h1>Object Moved</h1>This object may be found <a href="lumarquivos_ipn.asp">here</a>.</body>
</html>

<html><head><title>Object moved</title></head>
<body><h1>Object Moved</h1>This object may be found <a href="/arquivos1/lum-arquivos_ipn.asp?idioma=pt-BR&amp;status=">here</a>.</body>
</html>

<html><head><title>Object moved</title></head>
<body><h1>Object Moved</h1>This object may be found <a href="/arquivos1/lum-arquivos_ipn.asp?idioma=pt-BR&amp;status=ativo">here</a>.</body>
</html>

http://www.bmf.com.br/arquivos1/lum-arquivos_ipn.asp?idioma=pt-BR&status=ativo

而不是我想要的那个(它应该指向文件的位置)。我做错什么了?在


Tags: hereobjecttitlehtmlbodyh1headasp