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

PHP编程者 PHP编程者 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
这段代码当$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;
}
...全文

相关推荐

评论 11
收藏 已收藏
分享
返回顶部
PHP编程者
Framework 4,250 成员 4,522 内容