goutte - guzzle:表单提交后没有获得文件下载

时间:2016-11-08 19:13:13

标签: php guzzle goutte

我正在使用goutte单击表单中的按钮并获取文件的下载链接。我正确登录了该网站。 我使用的代码是在页面的其他部分已经使用的代码,并且在此之前给了我正确的结果,但在这种情况下,我不确定它是否足够:

$form = $crawler->selectButton('btn_name')->form();
$tableResults = $this->client->submit($form);
$result = $client->getResponse()->getContent(); // contains the same page of the form

按钮设置一些参数并通过ajax发送请求(因为页面在帖子后没有重新加载):

<button id="btn_id_was_long" name="btn_name" onclick="PrimeFaces.ab({source:'btn_name'});return false;" type="submit"><span>DAE</span></button>

当我检查响应的内容时,虽然我得到包含表单的html页面,但没有附件的痕迹。 当使用上面的代码单击按钮时,我得到以下标题作为响应:

Date: Tue, 08 Nov 2016 16:37:42 GMT 
Server: Apache/2.2.29 (Unix) mod_ssl/2.2.29 OpenSSL/1.0.1e-fips DAV/2 mod_jk/1.2.31 
X-Content-Type-Options: nosniff 
X-Frame-Options: SAMEORIGIN 
X-XSS-Protection: 1 
Liferay-Portal: Liferay Portal Enterprise Edition 6.2.10 EE GA1 (Newton / Build 6210 / November 1, 2013) 
X-JAVAX-PORTLET-FACES-NAMESPACED-RESPONSE: true X-Powered-By: JSP/2.2 
Transfer-Encoding: chunked Content-Type: text/html;charset=UTF-8

当我在浏览器中执行相同的操作时,我会通过文件下载来获取此信息:

HTTP/1.1 200 OK
Date: Tue, 08 Nov 2016 17:31:34 GMT
Server: Apache/2.2.29 (Unix) mod_ssl/2.2.29 OpenSSL/1.0.1e-fips DAV/2 mod_jk/1.2.31
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
X-XSS-Protection: 1
Content-Encoding: gzip
Liferay-Portal: Liferay Portal Enterprise Edition 6.2.10 EE GA1 (Newton / Build 6210 / November 1, 2013)
Content-Disposition: attachment;filename=DAE_00001_17/10/2016.pdf
Expires: 0
Pragma: public
Cache-Control: must-revalidate, post-check=0, pre-check=0 portlet.http-status-code: 200
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/pdf;charset=UTF-8

任何线索我做错了什么?

0 个答案:

没有答案