$header[] = 'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, text/html, * ' . '/* ';
    $header[] = 'Accept-Language: zh-cn ';
    $header[] = "User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0";

    $ch = curl_init(); //初始化curl

        //允许curl提交后,网页重定向
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

    //将curl提交后的header返回
    curl_setopt($ch, CURLOPT_HEADER, 1);
     //递归抓取LOCATION
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);     
    
    //以上处理重定向

    curl_setopt($ch, CURLOPT_URL, $url); //设置链接
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); //HTTPS必须设置不验证
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); //HTTPS必须设置不验证
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); //设置是否返回信息
    curl_setopt($ch, CURLOPT_HTTPHEADER,     $header); //设置HTTP头

    $html = curl_exec($ch); //接收返回信息

    curl_close($ch);

 

相关文章:

  • 2022-12-23
  • 2022-03-04
  • 2021-05-01
  • 2022-01-23
  • 2021-11-27
  • 2022-03-08
  • 2022-03-04
  • 2022-12-23
猜你喜欢
  • 2021-12-16
  • 2021-10-10
  • 2021-06-29
  • 2022-02-12
  • 2021-12-11
相关资源
相似解决方案