一段phpcurl代码

WBOY
Lepaskan: 2016-07-29 09:12:09
asal
957 orang telah melayarinya

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

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

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

    </span><span>//</span><span>将curl提交后的header返回</span>    curl_setopt(<span>$ch</span>, CURLOPT_HEADER, 1<span>);
     </span><span>//</span><span>递归抓取LOCATION</span>    curl_setopt(<span>$ch</span>, CURLOPT_FOLLOWLOCATION, 1<span>);     
    
    </span><span>//</span><span>以上处理重定向</span><span>    curl_setopt(</span><span>$ch</span>, CURLOPT_URL, <span>$url</span>); <span>//</span><span>设置链接</span>    curl_setopt(<span>$ch</span>, CURLOPT_SSL_VERIFYPEER, <span>FALSE</span>); <span>//</span><span>HTTPS必须设置不验证</span>    curl_setopt(<span>$ch</span>, CURLOPT_SSL_VERIFYHOST, <span>FALSE</span>); <span>//</span><span>HTTPS必须设置不验证</span>    curl_setopt(<span>$ch</span>, CURLOPT_RETURNTRANSFER, <span>TRUE</span>); <span>//</span><span>设置是否返回信息</span>    curl_setopt(<span>$ch</span>, CURLOPT_HTTPHEADER,     <span>$header</span>); <span>//</span><span>设置HTTP头</span><span>$html</span> = curl_exec(<span>$ch</span>); <span>//</span><span>接收返回信息</span><span>    curl_close(</span><span>$ch</span>);
Salin selepas log masuk

以上就介绍了一段phpcurl代码,包括了网页重定向方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan