Goutte icon indicating copy to clipboard operation
Goutte copied to clipboard

Scrap JSON data

Open ajay-patidar opened this issue 6 years ago • 4 comments

Hello,

I'm calling a URL that returns JSON, So how can I get that JSON response?

Thanks

ajay-patidar avatar Jul 13 '19 07:07 ajay-patidar

$crawler = $client->request('GET', 'https://url.com'); $crawler->html();

should return your json

seuaCoder avatar Sep 21 '19 04:09 seuaCoder

$crawler = $client->request('GET', 'https://url.com'); $crawler->html();

should return your json

PHP Fatal error: Uncaught InvalidArgumentException: The current node list is empty.

Noneatme avatar Jan 07 '20 12:01 Noneatme

$client->getResponse()->getContent()

jmichaelterenin avatar Jan 17 '20 17:01 jmichaelterenin

Response will ne in string so for using it you have to convert it into object or array using json decode function as provided in your server language as in php the function is json_decode which convert json string to object:

$result = json_decode($client->getResponse()->getContent());

Now you can iterate over $result object.

Haritsinh avatar May 26 '20 14:05 Haritsinh