Php curl cannot crawl content properly

function echo_var_dump($obj){
    echo "
";
    echo var_dump($obj);
    echo "
"; } Function GetCurl ($url) { / / curl forges useragent $useragent = array ( "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2)", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)", "Mozilla/5.0 (Windows; U; Windows NT 5.2) Gecko/2008070208 Firefox/3.0.1", "Opera/9.27 (Windows NT 5.2; U; zh-cn)", "Opera/8.0 (Macintosh; PPC Mac OS X; U; en)", "Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13", "Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" ); $curl = curl_init (); Curl_setopt ($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); Curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1); Curl_setopt ($curl, CURLOPT_URL, $url); / / set iP and useragent Curl_setopt ($curl, CURLOPT_REFERER, "http://h5.eqxiu.com/s/Rwg9jFlv"); Curl_setopt ($curl, CURLOPT_USERAGENT, array_rand ($useragent));) $resp = curl_exec ($curl); Curl_close ($curl); Return $resp; } $url = "http://s1.eqxiu.com/eqs/page/119805007?code=Rwg9jFlv&time=1523150497000"; $page_data = GetCurl ($url); $page_arr = json_decode ($page_data, true); Echo_var_dump ($page_arr);

I have set up REFERER, but the content is still incorrect. Visit the first link below to get the json content of the second link normally, and my program gets the prompt "data is illegal".

http://h5.eqxiu.com/s/Rwg9jFlv
http://s1.eqxiu.com/eqs/page/.

Mar.21,2021

//
curl_setopt($curl, CURLOPT_ENCODING, "gzip"); 
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Origin: http://h5.eqxiu.com']);

clipboard.png

clipboard.png



look at the illegal data. Where is the error reported? Does
need to construct cookie??


array_rand returns the array key, not value,userAgent is critical. After fix, take a look at


the browser can get it, and you set the ua header to output the obtained data. It should be a problem with your processor

.
Menu