我如何使用PHP curl获得此api的内容

时间:2018-08-09 11:50:36

标签: javascript php laravel curl

我正在尝试重现此api

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

但是问题是,当我尝试使用curl获取它时,会向我显示此重生头

HTTP/1.1 521 
Server: nginx
Date: Thu, 09 Aug 2018 11:45:39 GMT
Transfer-Encoding: chunked
Connection: keep-alive
X-Via-JSL: 79dfd01,-

体内带有此javescript代码

   <script>
     var x = "length@@https@@@@@while@@@0xEDB88320@eval@reverse@else@Array@setTimeout@hantom@@Aug@@18@@challenge@@RegExp@363@if@GMT@Thu@PiXG@firstChild@@1@href@g@@@document@new@@@8@charCodeAt@5k@join@1533815182@3D@as@return@@f@@addEventListener@div@@pathname@split@fromCharCode@46@captcha@O@function@location@Expires@match@rOm9XFMtA3QKV7nYsPGT4lifyWwkq5vcjH2IdxUoCbhERLaz81DNB6@DOMContentLoaded@@@attachEvent@@@0@var@3@4V7@chars@catch@@@d@@@0xFF@createElement@@String@try@@@@parseInt@for@__p@cookie@e@09@@window@charAt@substr@Path@toString@search@@12@toLowerCase@innerHTML@2@false@36@22@@JgSe0upZ@@onreadystatechange@@@@@@a@__jsl_clearance@@replace@1500@B@".replace(/@*$/, "").split("@"),
         y = "1t 2n=1h(){g('1i.y=1i.1b+1i.2e.2z(/[\\?|&]1f-n/,\\'\\')',2A);C.25='2x=11.q|1s|'+(1h(){1t 2p=[1h(2n){14 2n},1h(2p){14 2p},1h(2n){14 c('1G.1d('+2n+')')},1h(2n){23(1t 2p=1s;2p<2n.1;2p++){2n[2p]=22(2n[2p]).2d(2l)};14 2n.10('')}],2n=['1g',[(-~-~![]+[]+[])+[-~(+!{})]],'2j%',(-~-~![]+[]+[]),'2B',[(-~-~![]+[]+[])+((-~{}+[(-~-~![])*[-~-~![]]]>>-~{})+[])],[((-~{}+[(-~-~![])*[-~-~![]]]>>-~{})+[])+(~~!!29['24'+'h'+'13']+[])],[(-~-~![]+[]+[])+[(-~[]+[((+!+{})<<(+!+{}))]>>((+!+{})<<(+!+{})))+(-~[]+[((+!+{})<<(+!+{}))]>>((+!+{})<<(+!+{})))]],[-~(+!{})],'u',[[-~-~![]]/~~{}+[[]][1s]][1s].2a(~~{}),[(G+[[]][1s])+[(-~[]+[((+!+{})<<(+!+{}))]>>((+!+{})<<(+!+{})))+(-~[]+[((+!+{})<<(+!+{}))]>>((+!+{})<<(+!+{})))]],[(-~-~![]+[]+[])+(G+[[]][1s])],'I',[(-~[2j]+[]+[[]][1s])+[-~(+!{})]],'1v',[(-~[]+[((+!+{})<<(+!+{}))]>>((+!+{})<<(+!+{})))+(-~[]+[((+!+{})<<(+!+{}))]>>((+!+{})<<(+!+{})))]+[-~[]+(-~-~![]^-~(+!{}))]+(~~!!29['24'+'h'+'13']+[]),[[-~(+!{})]+(-~-~![]+[]+[]),(-~-~![]+[]+[])+(G+[[]][1s])],'z%12'];23(1t 1a=1s;1a<2n.1;1a++){2n[1a]=2p[[x,1u,x,1s,x,1u,2j,1u,1s,x,1s,2j,1u,x,1u,x,1s,1u,x][1a]](2n[1a])};14 2n.10('')})()+';1j=t, 27-j-l 2g:1e:2m s;2c=/;'};r((1h(){1H{14 !!29.18;}1x(26){14 2k;}})()){C.18('1m',2n,2k)}e{C.1p('2q',2n)}",
         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>

所以我注意到,这是一个JavaScript代码,它设置了一个名称为__jsl_clearance的cookie,以便如何在我的应用程序中使用此api

任何想法或解决方案

-更新这是我的curl代码-

$ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://www.zoomeye.org/api/search?q=facebook");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
    curl_setopt($ch, CURLOPT_COOKIEJAR, 'cook.txt'); 
    curl_setopt($ch, CURLOPT_COOKIEFILE, 'cook.txt');
    curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
    $headers = array();
    $headers[] = "Accept-Encoding: gzip, deflate, br";
    $headers[] = "Accept-Language: ar,en-US;q=0.9,en;q=0.8";
    $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: application/json, text/plain, */*";
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    echo $result = curl_exec($ch);
    curl_close ($ch);

谢谢.....

0 个答案:

没有答案