1、php采集天气预报代码=3600*3)self:get_($cache_file);$arr=unserialize(file_get_contents($cache_file);return $arr;/* 获得缓存* param unknown_type $cache_file*/static public function get_($cache_file)$con = file_get_contents(self:$domain.self:$url);preg_match(.*?)s,$con,$table);preg_match_all(.*?)s,$table1,$trs);$i=
2、0;$array = array();foreach ($trs1 as $tr)+$i;preg_match_all(.*?)s,$tr,$tds);$array0 = self:I($tds11);$array1 = self:I($tds12);$array01 = self:get_img($array01);$array11 = self:get_img($array11);file_put_contents($cache_file,serialize($array);/* 数据输出测试* param unknown_type $data* param unknown_type $s
3、*/static public function P($data,$s=0)echo “;if (is_array($data)var_export($data);elseecho $data;echo ;if ($s=0)exit();/* 转码* param unknown_type $str* return unknown*/static public function I($str)return iconv(GB2312,UTF-8,$str);/* 获得图片的 URL,此处可扩展,把图片抓取到本地, 增加访问速度* param string $str* return string*/static public function get_img($str)preg_match(src=“?(.*?)“? s,$str,$p);return self:$img.pathinfo($p1,PATHINFO_BASENAME);/print_r();$weather = weather:get();echo “;?