国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

php - curl抓取網(wǎng)頁正則匹配問題
黃舟
黃舟 2017-04-10 16:57:23
0
2
332

在Mac上寫的PHP代碼,可正常執(zhí)行,但是在Web Server上運行時會匹配不到。
Mac上PHP Version 5.5.30,CentOS 7服務(wù)器上的是PHP Version 5.6.15。
就是在執(zhí)行到第二個if時會保未找到該用戶!

//正則匹配頁面中的用戶信息,如果匹配成功則進(jìn)入編輯頁面
          if ($c = preg_match_all ('/(\/UserManage\/edit\/id\/\d*)/is', $search_result, $matches))
          {
            $string1 = $matches[1][0];

            //獲取頁面中的用戶信息,并進(jìn)入編輯頁面
             $match_user = curl_init();
            curl_setopt($match_user, CURLOPT_URL, 'https://crm.pzoom.com'.$string1);//登陸后要從哪個頁面獲取信息
            curl_setopt($match_user, CURLOPT_POST, 1);
            curl_setopt($match_user, CURLOPT_COOKIEFILE, PZOOM_COOKIE_FILE);// 獲取COOKIE文件
            curl_setopt($match_user, CURLOPT_RETURNTRANSFER, 1);//設(shè)定返回 的數(shù)據(jù)是否自動顯示
            curl_setopt($match_user, CURLOPT_HEADER, false);//設(shè)定是否顯示頭信 息
            curl_setopt($match_user, CURLOPT_NOBODY, false);//設(shè)定是否輸出頁面 內(nèi)容
            $edit_info = curl_exec($match_user);//返回結(jié)果
            curl_close($match_user); //關(guān)閉

            if ($c2=preg_match_all ('/(.*?value=\"(.*)\")/is', $edit_info, $edit_info_match))
            {

                if ($c3=preg_match_all ('/(.*?value=\"(.*)\") (checked)/is', $edit_info, $match_radio))
                {
                    
                }else{
                    echo "匹配失敗!";
                }

                if ($c4=preg_match_all ('/(textarea class="descript_cont" name="user\\[userDesc\\]" id="userDesc">)(.*)(<\/textarea>)/is', $edit_info, $match_textarea))

                {
                    
                }else{
                    echo "匹配失敗!";
                }

                $call_id = $edit_info_match[2][0];
                $user_userid = $edit_info_match[2][1];
                $user_name = $edit_info_match[2][2];
                $user_sex = $match_radiop[1][0];
                $user_tel = $edit_info_match[2][5];
                $user_mobile = $edit_info_match[2][6];
                $user_mail = $edit_info_match[2][7];
                $user_departmentid = $edit_info_match[2][9];
                $user_address = $edit_info_match[2][10];
                $call_areacode = $edit_info_match[2][12];
                $call_pwd = $edit_info_match[2][14];
                $user_desc = $match_textarea[2][0];
                $user_id = substr($string1,-4);

                //發(fā)起新的請求,并提交用戶輸入的分機號
                $edit_userinfor = curl_init();
                curl_setopt($edit_userinfor, CURLOPT_URL, 'https://crm.pzoom.com/UserManage/edit');//登陸后要從哪個頁面獲取信息
                curl_setopt($edit_userinfor, CURLOPT_POST, 1);
                $submit_userinfo = "call[id2]=$call_id&user[userid]=$user_userid&user[username]=$user_name&user[sex]=$user_sex&user[usertel]=$user_tel&user[usermobile]=$user_mobile&user[useremail]=$user_mail&user[departmentid]=$user_departmentid&user[address]=$user_address&call[cno]=$tel_number&call[areaCode]=021&isManager=1&call[pwd]=Aa123456&user[userDesc]=$user_desc&user[num]=1&user[id]=$user_id";
                curl_setopt($edit_userinfor, CURLOPT_POSTFIELDS, $submit_userinfo);//傳遞數(shù)據(jù)
                curl_setopt($edit_userinfor, CURLOPT_COOKIEFILE, PZOOM_COOKIE_FILE);// 獲取COOKIE文件
                curl_setopt($edit_userinfor, CURLOPT_RETURNTRANSFER, 1);//設(shè)定返回 的數(shù)據(jù)是否自動顯示
                curl_setopt($edit_userinfor, CURLOPT_HEADER, false);//設(shè)定是否顯示頭信 息
                $submint_userinfo = curl_exec($edit_userinfor);//返回結(jié)果
                curl_close($edit_userinfor); //關(guān)閉

            }else{
                die("未找到該用戶!");
            }
        }else{
            die("未找到該用戶!");
        }
      }

難道PHP版本不同,正則表達(dá)式也不一樣?

黃舟
黃舟

人生最曼妙的風(fēng)景,竟是內(nèi)心的淡定與從容!

reply all(2)
Ty80

好歹給個數(shù)據(jù)讓測試一下啊,光看能看出什么來

Peter_Zhu

因為抓取的是公司的OA系統(tǒng),所以不方便透露全部代碼,而且我在匹配后是要連接本地的數(shù)據(jù)庫,進(jìn)行數(shù)據(jù)匹配,填入相應(yīng)的值!
下面是我要匹配的頁面的表單:

<form action="" method="post" id="myform">
                        <input type="hidden" value="1010" name="call[id2]">
                        <ul class="clearfix">
                            <li><label><span><em>*</em>用戶名:</span><input type="text" name="user[userid]" id="userid" class="ipt custom_ipt" onblur="checkName()" value="yangtao"></label></li>
                            <li><label><span><em>*</em>真實姓名:</span><input type="text" name="user[username]" id="username" class="ipt custom_ipt" value="楊濤"></label></li>
                            <li><label><span>性別:</span>
                                <input type="radio" name="user[sex]" id="sex1" value="男">男&nbsp;
                                <input type="radio" name="user[sex]" id="sex2" value="女">女
                            </label></li>
                            <li><label><span>固定電話:</span><input type="text" name="user[usertel]" id="usertel" class="ipt" value=""></label></li>
                            <li><label><span>移動電話:</span><input type="text" name="user[usermobile]" id="usermobile" value="15800470152" class="ipt custom_ipt"></label></li>
                            <li><label><span><em>*</em>電子郵件:</span><input type="text" name="user[useremail]" id="useremail" value="yangtao@qiso360.com" class="ipt custom_ipt"></label></li>
                            <li style="position:relative;"><label><span><em>*</em>部門:</span>
                                <input type="text" class="ipt one_btn_client" id="departmentid" value="上分銷售部">
                                <input type="hidden" class="one_btn_search" name="user[departmentid]" value="89">
                                <ul class="client_list">
                                </ul>
                            </label></li> 
                        <li><label><span>詳細(xì)地址:</span><input type="text" name="user[address]" value="" class="ipt custom_ipt"></label></li>
                        <li><label><span>坐席工號:</span><input type="text" value="8451" name="call[cno]" class="ipt custom_ipt"></label>(工號取值范圍2000-9999)</li>
                        <li><label><span>坐席區(qū)號:</span><input type="text" value="021" name="call[areaCode]" class="ipt custom_ipt"></label>(座席所在地區(qū)區(qū)號)</li>
                        <li><label><span>是否管理人員:</span><input type="radio" name="isManager" value="1" checked="">否 <input type="radio" name="isManager" value="2">是</label></li>
                        <li><label><span>坐席密碼:</span><input type="text" value="Aa123456" name="call[pwd]" class="ipt custom_ipt"></label>(不填為默認(rèn)密碼123456)</li>
                        <li><label><span>描述信息:</span><textarea class="descript_cont" name="user[userDesc]" id="userDesc"></textarea></label></li>
                        <li><label><span>狀態(tài):</span><input type="radio" name="user[num]" value="1" checked="">正常&nbsp;&nbsp;<input type="radio" name="user[num]" value="2">凍結(jié)&nbsp;&nbsp;<input type="radio" name="user[num]" value="3">離職</label>
                        </li>
                        </ul>
                        <p class="add_custom_add">
                            <input type="hidden" name="user[id]" id="uid" value="3408">
                            <input type="button" value="保存" class="btn_add" id="bbs">
                            <a href="/UserManage/userinfo" class="btn_add">返回</a>
                        </p>
                    </form>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template