您的位置:首页 > 编程语言 > PHP开发

PHP抓取天气预报的代码

2007-10-18 12:33 211 查看

$strurl="http://www.cma.gov.cn/tqyb/weatherdetail/54511.html";


$strhtmlarray=file($strurl);


$strlinehtml= implode('', $strhtmlarray);


eregi("3天预报(.*)指数查询", $strlinehtml, $head);


$head[0]=strip_tags($head[0]);


$head[0]=str_replace(" "," ",strip_tags($head[0]));




$head[0]=str_replace("3天预报","",$head[0]);


$head[0]=str_replace("时间","",$head[0]);


$head[0]=str_replace("天气概况","",$head[0]);


$head[0]=str_replace("气 温","",$head[0]);


$head[0]=str_replace("风向/风力","",$head[0]);


$head[0]=str_replace("指数查询","",$head[0]);


$head[0]=str_replace(" ","",$head[0]);


$result=preg_replace("/s+/", "|", $head[0]);


$resultarray=preg_split("/[|]/",$result);


//zm_cache::cache_write("weather",$result);


print_r($result);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: