首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

这段代码总是在2m左右出现504 Proxy Timeout异常,什么原因

2013-06-19 
这段代码总是在2m左右出现504 Proxy Timeout错误,什么原因?本帖最后由 helloqhq 于 2010-12-23 10:03:26

这段代码总是在2m左右出现504 Proxy Timeout错误,什么原因?
本帖最后由 helloqhq 于 2010-12-23 10:03:26 编辑 这段代码当$fucknum比较大时,比如1000时,就会出现504 Proxy Timeout错误,而且报错后程序不再继续执行,好像停止不前了,$fucknum值比较小时不会出现这个错误,什么原因?请各位指点下

function autonewnewegg($arr){
            $fucknum=intval($arr['fucknum']);  // # 获取抓取条数的整数值
            $outime=$fucknum*2+100;
            set_time_limit($outime);//设置脚本执行时间
            $nextnum=20;//连续查找10次不存在则终止
            $sn=$arr['sn'];
            
            $acl=explode("-",$sn);
            $acl_1=preg_replace('/[^0-9]+/','',$acl[1]);        //二次
            $a=$b=0;                                            //二次
            
            while($fucknum>0){
                $arr1 = $arr2 = array();
                if($acl[2]<1000&&$acl_1<100){
                    $acl[2]=str_pad("$acl[2]",3,'0',STR_PAD_LEFT);
                    $acl_1=str_pad("$acl_1",2,'0',STR_PAD_LEFT);
                    $acl[1]="c".$acl_1;
                    $arr_in=implode("-",$acl);
            
                    $url=$GLOBALS['competitor'][1]['product'].$arr_in.'.htm';
                    if($acl[2]==999){
                        $acl_1=$acl_1+1;
                        $acl[2]=001;
                    }else {
                        ++$acl[2];
                    }
                }elseif($acl[0]<=99){
                    $acl[0]=str_pad("$acl[0]",2,'0',STR_PAD_LEFT);


                    $arr_in=implode("-",$acl);
                    
                    $acl[2]=001;
                    $acl_1=01;
                    ++$acl[0];
                    $url=$GLOBALS['competitor'][1]['product'].$arr_in.'.htm';
                }
                $str = file_get_contents($url);
                if(!$str){
                    $fucknum--;
                }else{
                    $preg ='/href="http:\/\/www\.newegg\.com\.cn\/SubCategory\/(\d*)\.htm">/';
                    $preg2 ='/<h1>(.*)<\/h1>/';
                    
                    $str = iconv("gbk","UTF-8",$str);
                    preg_match($preg,$str,$arr1);
                    preg_match($preg2,$str,$arr2);
                    if(empty($arr1) || empty($arr2)){
                        $fucknum--;
                    }else{
                        $price = $this->ocr_newegg($url);
                        if ($price == false||$price=='.'){
                            $price = $this->ocr_newegg1($url);
                        }
                        if($price == false){
                        }else{
                            $autoarr=array('cid'=>$arr1[1],'name_newegg'=>$arr2[1],'price_newegg'=>$price,'sn_newegg'=>$arr_in);


                            $this->addnew_newegg($autoarr);
                        }
                        $fucknum--;
                    }
                }
            }
            return true;
        }

热点排行