Blogger Information
Blog 5
fans 0
comment 0
visits 3161
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php_curl基础
gzg1023
Original
917 people have browsed it

//初始化curl

$ch = curl_init();


//设置代理,很多时候我们可以用来调试程序,或者切换代理ip来采集一些放采集的网站

//curl_setopt ($ch, CURLOPT_PROXY,'127.0.0.1:8888');


//设置要提交的url

curl_setopt($ch, CURLOPT_URL, "https://www.noxue.com");


//是否显示头信息

curl_setopt($ch, CURLOPT_HEADER, true);


//设置超时时间

curl_setopt($ch, CURLOPT_TIMEOUT, 30);


// CURLOPT_FOLLOWLOCATION为true,则会跟踪爬取重定向页面,否则,不会跟踪重定向页面。

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);


//是否验证ssl证书,请求https的时候,设置为false表示不验证

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);


//设置ua信息

curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'");


//来路地址

curl_setopt($ch, CURLOPT_REFERER, "https://www.noxue.com");


//是否返回内容,如果设置为fase的话,表示直接输出到页面,就不会在curl_exec执行的时候返回内容。设置为true时才会返回。

curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);

//执行curl请求

curl_exec($ch);


//关闭curl连接

curl_close($ch);


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post