Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
478 views
in Technique[技术] by (71.8m points)

php模拟post提交微信验证码,总是提交不上去

我想要采集微信,但是微信采集次数过于频繁的时候会出来验证码,我就找了个打码平台自动打码,但是现在拿到验证码的code以后,再去做提交,总是失败,想请问各路豪杰,这玩意怎么整?

$cont = curl_getbyurl ( $url );//我自己封装的一个curl,其中获得了cookie并存到cookie.txt文件中
    if (strpos ( $cont, '请输入验证码' ) !== false) {
        echo '需要验证码';

        $thistime = microtime ( true );
        $picurl = 'http://mp.weixin.qq.com/mp/verifycode?cert='.$thistime;

        $picname='E:/yanzhengma/yanzhengma'.$thistime.'.jpg';
        $url=file_get_contents($picurl);//获得验证码
        file_put_contents($picname,$url);//把验证码存到一个文件夹里

        //自动打码
        $piccode = autopic($picname);//自己封装的一个验证自动打码
        $piccode = $piccode->Result;//获得验证码的code
        if($piccode){

            $codeurl="http://mp.weixin.qq.com/mp/verifycode";
            $post = "cert=$thistime&input=$piccode";
            $code_curl = curl_init();
            curl_setopt($code_curl, CURLOPT_POST, 1);
            curl_setopt($code_curl, CURLOPT_URL, $codeurl);
            curl_setopt($code_curl, CURLOPT_POSTFIELDS, $post);
               curl_setopt ($code_curl, CURLOPT_COOKIEFILE, $cookie_file); 
               curl_setopt ($code_curl, CURLOPT_SSL_VERIFYPEER, 0 ); // 对认证证书来源的检查
               curl_setopt ($code_curl, CURLOPT_SSL_VERIFYHOST, 1 ); // 从证书中检查SSL加密算法是否存在
               curl_setopt ($code_curl, CURLOPT_USERAGENT, $_SERVER ['HTTP_USER_AGENT'] ); // 模拟用户使用的浏览器
            $result=curl_exec($code_curl);
            curl_close($code_curl);
            var_dump($result);
            unlink($cookie_file);
        }

        die ();
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

自己模拟一次验证码提交咯


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...