用php 類比趕集發布房源時 ,類比登陸後,一會時間就不能登陸了,需要驗證碼 , 看怎麼能處理下,請教下有經驗的朋友 ,謝謝 !
$url = "https://passport.ganji.com/login.php"; $data ="login_username=wangsheng6666666666&login_password=".trim(decode('bGlqaWF3YW5nc2hlbmcyMDEz')); // $imageurl= 'https://passport.ganji.com/ajax.php?dir=captcha&module=login_captcha&nocache=1445313015271'; $redata= $publish->vlogin($url,$data,$url,true); function vlogin($url,$data,$REFERER =null,$ishttps=true){ // $curl = curl_init(); // 啟動一個CURL會話 curl_setopt($curl, CURLOPT_URL, $url); // 要訪問的地址 curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 類比使用者使用的瀏覽器 if(empty($REFERER)) { curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自動化佈建Referer }else{ curl_setopt($curl, CURLOPT_REFERER, $REFERER);// 設定Referer } if($ishttps) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 對認證認證來源的檢查 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); // 從認證中檢查SSL密碼編譯演算法是否存在 } curl_setopt($curl, CURLOPT_POST, 1); // 發送一個常規的Post請求 curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的資料包 // curl_setopt($curl, CURLOPT_COOKIEFILE, $this->cookie_file); // 讀取上面所儲存的Cookie資訊 // curl_setopt($curl, CURLOPT_COOKIEJAR, $this->cookie_file); // 存放Cookie資訊的檔案名稱 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 擷取的資訊以檔案流的形式返回 curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 設定逾時限制防止死迴圈 curl_setopt($curl, CURLOPT_HEADER, 1); $tmpInfo = curl_exec($curl); // 執行操作 if (curl_errno($curl)) { echo 'Errno'.curl_error($curl); } // preg_match_all('/Set-Cookie:stest=(.*)/i', $tmpInfo, $tmpInfo); curl_close($curl); // 關閉CURL會話 return $tmpInfo; // 返回資料 }
請大家幫忙看看 謝謝
回複討論(解決方案)
你發布房源 太頻繁了吧。?
驗證碼 你能搞定?? 估計大神來了一樣搞不定
驗證碼 彈出識別 輸入 是一項大工程
估計難道屬於A++ 識別率一般都很差
驗 證嗎,只有把它輸出來 讓人工輸入,顯人工輸入,找個打碼平台對接
驗證碼沒有辦法自動識別,即使能識別,也是很簡單的那種,我最後,採用直接輸入的方式,處理了 謝謝,各位了
php curl 擷取驗證碼時 ,需要擷取cookie,這樣,提交驗證時,採用同樣的cookie ,就可以了