Chinaunix首页 | 论坛 | 博客
  • 博客访问: 195846
  • 博文数量: 63
  • 博客积分: 1002
  • 博客等级: 准尉
  • 技术积分: 640
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-11 20:34
文章分类

全部博文(63)

文章存档

2017年(2)

2015年(3)

2013年(4)

2012年(21)

2011年(33)

分类: Web开发

2013-02-04 10:39:49


header("Content-type: text/html; charset=utf-8");
$rand = time();
$name = 'zhongtong';//快递名称编号  中通
$id = '123456';//快递单号
$url = "";
//采集html 
$ch = curl_init(); 
$timeout = 10; 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); 
$contents = trim(curl_exec($ch)); 
curl_close($ch); 
//获得标题和url 
$string = $contents;
//正则匹配

  • 获取标题和地址 
    preg_match_all ("/

    (.*)<\/p>/",$string, $out, PREG_PATTERN_ORDER); 
    if(strpos($out[0][1], "建议操作")!=false){
    echo "";
    }else{
    $str="";
    //$str.=$out[0][0];
    $str.=$out[0][1];
    $str.=$out[0][2];
    echo $str;
    }
    ?>

  • 阅读(1511) | 评论(0) | 转发(0) |
    给主人留下些什么吧!~~