You’re probably not getting it because the site blocks some requests and asks to confirm that it’s not a robot.
This protection works basically as follows:
Upon entering the site, the code checks whether or not the request has the cookie cf_clearance
with a token
valid, if it does not display the reCaptcha
google.
After the user confirms that he is not a robot, the server returns a cookie with a token
.
Already the site jsonformatter.org, probably uses cookies
to circumvent this protection. In php
, would be more or less that way:
<?php
/* Inicia a biblioteca cURL com a URL */
$ch = curl_init("https://www.cryptocompare.com/api/data/coinsnapshotfullbyid/?id=1182");
/* Informa que deseja capturar o resultado */
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
/* Desabilita a verificação do certificado SSL */
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
/* Informa o Cookie com o token válido para burlar a proteção */
curl_setopt($ch, CURLOPT_COOKIE, "cf_clearance=3def377bda6f9be22251eff64cb617c157011246-1518023345-604800");
/* Define o User-Agent para burlar a proteção */
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36");
/* Captura a resposta */
$response = curl_exec($ch);
/* Captura os erros, caso haja */
$error = curl_error($ch);
/* Captura as informações da requisição */
$info = curl_getinfo($ch);
/* Fecha a requisição e exibe o resultado */
curl_close($ch);
echo($response);
it would be interesting to put what you tried to do so we could help you
– Otto
You’re probably not getting it because the site blocks some requests and asks to confirm that it’s not a robot.
– Valdeir Psr
@Valdeirpsr But how can https://jsonformatter.org/ do it?
– Gilberto Junior