php 抓取天气情况 www.weather.com.cn

",$result);
	$result = explode("
",$result[1]); $result = mb_convert_encoding($result[0],"GBK","UTF-8"); $first = explode("
",$result); //print_r($first);exit; $w1 = get_we_info($first[0]); $w2 = get_we_info($first[1]); $week = mb_substr($w1[0],-2); $arr['w_week'] = $week; $arr['w_day1'] = trim($w1[1]); $arr['w_day2'] = trim($w2[1]); $arr['w_type1'] = trim($w1[2]); $arr['w_type2'] = trim($w2[2]); $arr['w_temperature1']= trim($w1[3]); $arr['w_temperature2']= trim($w2[3]); return $arr; } /** * 每天的详细天气状况(今天 白天->今天 夜间) * @param unknown $info * @return string */ function get_we_info($info){ $w_info=explode("",$info); $we_arr[0] = strip_tags($w_info[0]); $w_info=explode("",$w_info[1]); $we_arr[1] = strip_tags($w_info[0]); $w_info = explode("

",$w_info[1]); $we_arr[2] = strip_tags($w_info[0]); $w_info=explode("",$w_info[1]); //$w_info=explode("

",$w_info[1]); $we_arr[3]=strip_tags($w_info[0]); return $we_arr; } ?>


你可能感兴趣的:(PHP)