摘要:在php使用curl时必须先在php ini中开启extension=php_curl dll前面的;去了才行,curl是php中一款内置的浏览器,它可以模仿用户浏览信息进行网站浏览,等下面来看一实例,代码如下:functionpostpage($ur...
转载请注明来源:php curl用法
在php使用curl时必须先在php.ini中开启extension=php_curl.dll前面的;去了才行,curl是php中一款内置的浏览器,它可以模仿用户浏览信息进行网站浏览,等下面来看一实例,代码如下:
- function postpage($url)
- {
- $response = "";
- $rd=rand(1,4);
- $proxy='http://221.214.27.253:808';
- if($rd==2) $proxy='http://222.77.14.56:8088';
- if($rd==3) $proxy='http://202.98.123.126:8080';
- if($rd==4) $proxy='http://60.14.97.38:8080';
- if($url != "") {
- $ch = curl_init($url);
- curl_setopt($ch, curlopt_header, 0);
- curl_setopt($ch, curlopt_returntransfer, true);
- curl_setopt($ch, curlopt_proxy, $proxy);
- $response = curl_exec($ch);
- if(curl_errno($ch)) $response = "";
- curl_close($ch);
- }
- return $response;
- }
curl包括部份函数,如下所示:
转载请注明来源:php curl用法
- curl_close — close a curl session
- curl_copy_handle — copy a curl handle along with all of its preferences
- curl_errno — return the last error number
- curl_error — return a string containing the last error for the current session
- curl_exec — perform a curl session
- curl_getinfo — get information regarding a specific transfer
- curl_init — initialize a curl session
- curl_multi_add_handle — add a normal curl handle to a curl multi handle
- curl_multi_close — close a set of curl handles
- curl_multi_exec — run the sub-connections of the current curl handle
- curl_multi_getcontent — return the content of a curl handle if curlopt_returntransfer is set
- curl_multi_info_read — get information about the current transfers
- curl_multi_init — returns a new curl multi handle
- curl_multi_remove_handle — remove a multi handle from a set of curl handles
- curl_multi_select — wait for activity on any curl_multi connection
- curl_setopt_array — set multiple options for a curl transfer
- curl_setopt — set an option for a curl transfer
- curl_version — gets curl version information
哈尔滨品用软件有限公司致力于为哈尔滨的中小企业制作大气、美观的优秀网站,并且能够搭建符合百度排名规范的网站基底,使您的网站无需额外费用,即可稳步提升排名至首页。欢迎体验最佳的哈尔滨网站建设。