【发布时间】:2014-07-29 00:49:00
【问题描述】:
我必须在请求中使用 cookie 下载图像。我可以使用 file_get_contents (使用 stream_context_create)或 curl 通过传递 cookie 来实现。但是如何使用 Goutte 来实现呢?
use Goutte\Client;
$client = new Client();
$response = $client->request('GET', 'https://www.google.pl/images/srpr/logo11w.png');
我提出了一个 GET 请求,下一步是什么?
好的,我想通了:
$client->get('https://www.google.pl/images/srpr/logo11w.png', array('save_to' => __DIR__.'/image.jpg'));
【问题讨论】:
标签: php cookies curl web-scraping goutte