![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
相关问题
跟据LuckLrj兄的做了点小的修改
原地址: http://www.phpx.com/happy/viewth ... hlight=%CC%EC%C6%F8
[php]
<?php
@header("content-type:text/html;charset=utf-8");
$city = $_POST['city']?$_POST['city']
_GET['city'];
$url = "http://weather.tq121.com.cn/detail.php?city=".$city;
$contents = file_get_contents($url);
$contents=strstr($contents,"
| ",$contents); $contents = $tmp[0]; $contents = iconv("GB2312", "UTF-8", $contents); preg_match_all("/\/([a|0][0-9]{1,2}\.gif)/si",$contents,$arr_img);//取图片 if($arr_img['1']['0']) { //存在数据的时候才执行更多取数据操作 preg_match_all("/([^>]*?)<\/span>/si",$contents,$arr_word);//取文字 preg_match_all("/([^>]*?)<\/span>/si",$contents,$arr_city);//取城市名 print_r($arr_img); print_r($arr_word); print_r($arr_city); } else { echo "对不起,您所查询的城市不存在!"; } ?> [/php] |

