I want to parse the site using Kurla. But the result is an error 302 Found nginx. Here is the code: function curl ($ url)

{ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, " Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0 .2564.109 Safari/537.36"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_MAXREDIRS, 10); $output = curl_exec($ch); curl_close($ch); return $output; } $auth = curl($link ); $parser = phpQuery::newDocument($auth); echo $parser; 

What's the mistake? Thanks.

    1 answer 1

    A 302 code means that the document is not available at the current address, but the Location header was sent with the address where the document is available.

    To make CURL automatically go to this URL, add to the code before curl_exec:

     curl_setopt($ch, CURLOPT_FOLLOWLOCATION , true); 
    • it helped, but now another problem - automatic redirect to the site itself after uploading - Roma Tulaydan