PHP CURL,无法从API获取数据

时间:2018-08-07 14:34:50

标签: php curl php-curl

我的代码有问题,我不为什么....

问题是,如果我尝试在浏览器中打开此API

https://www.zoomeye.org/api/search?q=facebook

它会很好用

但是如果我尝试使用代码获取数据,它将显示此内容

<script>var x="@false@0@RegExp@36@Tue@new@@k@addEventListener@@@createElement@replace@@@@g@@__jsl_clearance@href@@if@f@@FfGa@Path@@for@substr@pathname@String@@1533651699@fromCharCode@var@@length@@JgSe0upZ@search@@@694@e@0xEDB88320@@@@0xFF@@@rOm9XFMtA3QKV7nYsPGT4lifyWwkq5vcjH2IdxUoCbhERLaz81DNB6@@3D@chars@catch@15@@18@parseInt@firstChild@div@2FHcUZg3z@@@https@reverse@@21@@join@@toLowerCase@1@captcha@07@@kOB@@@match@challenge@window@eval@1500@Array@@@@@Expires@onreadystatechange@8@@Aug@split@3@d@@try@else@while@@@DOMContentLoaded@PQ@charCodeAt@toString@a@location@GMT@2@@charAt@1aO@@39@function@@@@return@setTimeout@attachEvent@document@innerHTML@cookie".replace(/@*$/,"").split("@"),y="2a 22=92(){97('87.18=87.25+87.32.11(/[\\?|&]5b-65/,\\'\\')',68);99.9b='17=28.35|3|'+(92(){2a 33=[92(22){96 22},92(33){96 33},(92(){2a 22=99.10('4b');22.9a='<86 18=\\'/\\'>3a</86>';22=22.4a.18;2a 33=22.64(/52?:\\/\\//)[3];22=22.24(33.2c).59();96 92(33){23(2a 3a=3;3a<33.2c;3a++){33[3a]=22.8b(33[3a])};96 33.57('')}})(),92(22){23(2a 33=3;33<22.2c;33++){22[33]=49(22[33]).85(5)};96 22.57('')}],22=[[[(-~{}<<-~{})]+((+!{})+[]+[])],'8c',[((+![][{}])+[]+[])+((+![][{}])+[]+[])],'%4c',[89+((+![][{}])<<89)],[[(-~{}<<-~{})]+((+!{})+[]+[])],'9',[+[(+![][{}]), ~~{}]+[]+[]][3].8b((+![][{}])+(+![][{}])),'61%',[(-~{}<<-~{})],'20',[+[(+![][{}]), ~~{}]+[]+[]][3].8b((+![][{}])+(+![][{}])),'83%43'];23(2a 3a=3;3a<22.2c;3a++){22[3a]=33[[77,5a,77,5a,3,77,5a,3,5a,3,5a,3,5a][3a]](22[3a])};96 22.57('')})()+';71=6, 5c-75-48 46:55:91 88;21=/;'};1a((92(){7a{96 !!66.a;}45(36){96 2;}})()){99.a('82',22,2)}7b{99.98('72',22)}",f=function(x,y){var a=0,b=0,c=0;x=x.split("");y=y||99;while((a=x.shift())&&(b=a.charCodeAt(0)-77.5))c=(Math.abs(b)<13?(b+48.5):parseInt(a,36))+y*c;return c},z=f(y.match(/\w/g).sort(function(x,y){return f(x)-f(y)}).pop());while(z++)try{eval(y.replace(/\b\w+\b/g, function(y){return x[f(y,z)-1]||("_"+y)}));break}catch(_){}</script>

我发现浏览器中有2个Cookie

第一个:具有值的__jsl_clearance:

1533649653.253|0|qezZITBFLfsxO0ZNNeYi5zJ8UKg%3D

另一个是__jsluid的值:

50d77a6c73a7c1e2ab5e7af2807e44a1

如果我阻止了其中一个cookie,我将获得与卷发相同的重生

这是我的php代码

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.zoomeye.org/api/search?q=facebook");
curl_setopt($ch, CURLOPT_COOKIEJAR, './cookie.txt');// set where cookies will be stored
curl_setopt($ch, CURLOPT_COOKIEFILE, './cookie.txt');// from where it will get cookies
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$headers = array();
$headers[] = "Connection: keep-alive";
$headers[] = "Cache-Control: max-age=0";
$headers[] = "Upgrade-Insecure-Requests: 1";
$headers[] = "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36";
$headers[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8";
$headers[] = "Accept-Encoding: gzip, deflate, br";
$headers[] = "Accept-Language: ar,en-US;q=0.9,en;q=0.8";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
curl_close ($ch);
echo $result;

所以我该如何解决此问题....当我运行php代码时,此cookie“ __jsluid”仅存储在我的cookie文件中,而我同时需要cookie“ __jsl_clearance”和“ __jsluid”才能获得json重生< / p>

0 个答案:

没有答案
相关问题