使用Goutte / Guzzle客户端获取json数据

时间:2017-05-06 12:39:27

标签: php http web-crawler guzzle goutte

尝试使用Guzzle客户端($request = $client->getClient()->createRequest('GET', 'http://.../api'); $response = $request->send(); $json_data = $response->json();

获取json数据
[Symfony\Component\Debug\Exception\FatalThrowableError]
Type error: Argument 3 passed to GuzzleHttp\Client::request() must be of the type array,
string given, called in /var/www/.../vendor/guzzlehttp/guzzle/src/Client.php on line 87

错误:

$crawler = $client->request("GET", "http://.../api");
$json_data = $crawler->text();

尝试使用抓取工具

[InvalidArgumentException]
The current node list is empty.

错误:

Federkun

修改

请参阅$json_data = $client->getResponse()->getContent(); 的评论。

解决方案:

{{1}}

0 个答案:

没有答案