为了实现注册机才写的教程,为了批量注册一个网站,注册带有验证码,幸好是文本验证码,但是有session验证,于是POST必须携带cookie。代码如下。
<?php class AutoCurl{ private $curl; private $strCookie; public $url; public $data; function __construct(){ $this->curl=curl_init(); $this->strCookie='tmp.cookie'; if(!file_exists('tmp.cookie')){ $ckfile = fopen("tmp.cookie", "w") or die("Unable to open file!"); fclose($ckfile); } } function __destruct(){ curl_close($this->curl); } function CurlGet(){ curl_setopt($this->curl, CURLOPT_URL, $this->url); curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true) ; curl_setopt($this->curl, CURLOPT_BINARYTRANSFER, true) ; //important curl_setopt($this->curl,CURLOPT_CONNECTTIMEOUT, 5); //save_cookie curl_setopt($this->curl,CURLOPT_COOKIEJAR,$this->strCookie); $output = curl_exec($this->curl) ; return $output; } function CurlPost(){ curl_setopt($this->curl,CURLOPT_POST,1); //send_cookie curl_setopt($this->curl,CURLOPT_COOKIEFILE, $this->strCookie); curl_setopt($this->curl,CURLOPT_RETURNTRANSFER, 1); curl_setopt($this->curl,CURLOPT_URL,$this->url); curl_setopt($this->curl,CURLOPT_POSTFIELDS,$this->data); $output = curl_exec($this->curl) ; return $output; } } //实例化一个会话 $newcurl= new AutoCurl(); //第一步GET获取Cookie和验证码 //设置登录填充的Url $newcurl->url='http://www.jinghong.in/index.php?m=user&mod=reg'; //发送Get $result=$newcurl->CurlGet(); //获取验证码 if(preg_match('/\<b\>(.*)\<\/b\>/U',$result, $matches)){ $code=$matches[1]; } //第二步POST提交注册 //设置登录提交的Url $newcurl->url='http://www.jinghong.in/index.php?m=user&mod=reg&act=ok'; //设置发送POST数据 $newcurl->data=array("name" =>'a'.rand(pow(10,(6-1)), pow(10,6)-1),"sj" => "1".rand(pow(10,(11-1)), pow(10,11)-1),"email" =>rand(pow(10,(5-1)), pow(10,5)-1)."@qq.com","pass" => rand(pow(10,(7-1)), pow(10,7)-1)."qqcom","bzyzm" => $code); //发送Post $result=$newcurl->CurlPost(); var_dump($result); ?>
//参数1 文件名 参数2 缩放比例 function _thumb($_filename,$_percent){ ob_clean();...
function objtoarr($obj){ $ret = array(); foreach($obj as $key =>$value){ if(gettype($value) == 'arr...
首先下载wkhtmltox-0.12.4_linux-generic-amd64.tar.xz (不要下载RPM包,依赖太多,需要x-server支持),并解压,执行测试运行正常tar wkhtmltox-0.12.4_linux-generic-amd64.tar.xzcd...
第一步:服务端文件<?php $wsdlfile='webservice.wsdl'; ini_set('soap.wsdl_cache_enabled','0'); //关闭WSDL缓存 //001...
if($_SERVER['REQUEST_METHOD'] == 'POST') { echo('This is post '); } elseif ($_SERVER['...
php官方的超全局变量$_SERVER['PHP_SELF']也能直接获取,只不过如果url参数太多也会获取。下面提供一个方法获取/* * 获取当前PHP文件名称 */ if (!function_exists('phpself...