ems快递查询页面远程截取单号信息出问题,不允许使用curl 代码如下:
ems.php源码:<?php
!defined('IN_TW')&&exit('Access Denied'); $request=new HttpClient('www.ems.com.cn');
// $request->setDebug(true);
$request->referer='http://www.ems.com.cn/';
$data=array(
'reqCode'=>'browseBASE',
);
!$request->post('/qcgzOutQueryNewAction.do',$data)&&exit('Sorry!连接服务器失败,请刷新该页面,或五分钟后再次查询');
$cookies=$request->getCookies();
$html=$request->getContent();
// echo $html;

$TW_SESSION='JSESSIONID='.$cookies['JSESSIONID']; $start_pos=strpos($html,'name="myEmsbarCode"');
$len=strpos($html,'maxlength="5"',$start_pos)-$start_pos;
$html=substr($html,$start_pos,$len);

// echo $html;
// exit;

$start_pos=strpos($html,'value="')+7;
$len=strpos($html,'"',$start_pos)-$start_pos;
$myEmsbarCode=substr($html,$start_pos,$len); $start_pos=strrpos($html,'<input');
$start_pos=strpos($html,'name="',$start_pos)+6;
$len=strpos($html,'"',$start_pos)-$start_pos;
$seccodeName=substr($html,$start_pos,$len); unset($html,$request,$start_pos,$len); $moreFields='<input type="hidden" name="reqCode" value="browseBASE">';
$moreFields.='<input type="hidden" name="myEmsbarCode" value="'.$myEmsbarCode.'">';
$moreFields.='<input type="hidden" name="verifyName" value="'.$seccodeName.'" />';?>do.php源码:<?php
!defined('IN_TW')&& exit('Access Denied');
$request=new HttpClient('www.ems.com.cn');
//    $request->setDebug(true);
$request->setCookies($TW_SESSION);
$request->referer='http://www.ems.com.cn/qcgzOutQueryNewAction.do'; $_POST['mailNum']=$_POST['mailNo'];
$_POST[$_POST['verifyName']]=$_POST['verifyCode'];
!$request->post('/qcgzOutQueryNewAction.do',$_POST)&&exit($request->getError());
$html= $request->getContent();
header('Content-type:text/html;charset=gb2312');
echo trimHtml($html);function trimHtml($html){
$json=array(
'status'=>0,
'message'=>'',
'data'=>array()
);
if(strpos($html,'class="message"')!==false)
{
$start_pos=strpos($html,'class="message">')+16;
$start_pos=strpos($html,'>',$start_pos)+1;
$len=strpos($html,'<br',$start_pos)-$start_pos;
$html=trim(substr($html,$start_pos,$len));
$json['message']=$html;
return gbk_json_encode($json); }
$qianshou='';
if(($pos=strpos($html,'<td class="txt-main" align="left"><strong>'))!==false && ($pos=strpos($html,'<span class="txt-basic-info-e-time">',$pos))!==false){
// $pos=strpos($html,'<span class="txt-basic-info-e-time">',$pos);
$len=strpos($html,'</strong>',$pos)-$pos;
$qianshou=substr($html,$pos,$len);
$time=strip_tags(substr($qianshou,0,strpos($qianshou,'</span>')));
$context=strip_tags(substr($qianshou,strpos($qianshou,'</span>')));
$qianshou=array(
'time'=>trim($time),
'context'=>trim($context)
);
}
$start_pos=strpos($html,'td class="txt-main" align="left">')+33;
$start_pos=strpos($html,'<table',$start_pos);
$start_pos=strpos($html,'</tr>',$start_pos)+5;
$len=strpos($html,'</table>',$start_pos)-$start_pos;
$html=substr($html,$start_pos,$len);
$rows=explode('</tr>',$html);
array_walk($rows,'array_strip_tags','<td>');
$rows=array_filter($rows); $date='';
$json['status']=1;
foreach($rows as $row){
$cell=explode('</td>',$row);
$time=str_replace('&nbsp;','',trim(strip_tags($cell[1])));
$context=trim(strip_tags($cell[2])).trim(strip_tags($cell[3]));
if(!$time && !$context)continue;
if($time[4]=='-' || $time[4]=='/'){
   $date=substr($time,0,10);
$time=$date.' '.substr($time,10);
}else{
$time=$date.' '.$time;
}
$json['data'][]=array(
'time'=>$time,
'context'=>$context
); }
if(is_array($qianshou)){
//        array_pop($json['data']);
$json['data'][]=$qianshou;
}
return gbk_json_encode($json);
}
?>verifyImage.php源码:<?php
    !defined('IN_TW')&&exit('Access Denied');
    $request=new HttpClient('www.ems.com.cn');
//    $request->setDebug(true);
    $request->setCookies($TW_SESSION);
    !$request->get('/servlet/ImageCaptchaServlet')&&exit($request->getError());
    header('Content-type:image/jpeg');
    print($request->getContent());
?>有问题的页面:http://kuaidiwo.duapp.com/ems.php 输入验证码后提示:页面停留时间过长导致邮件查询标志丢失,请刷新查询页面。 谁能搞定可以联系我QQ862470929 重谢!