获取IP有两种方法,复杂的被我注释掉了,如果你想使用复杂的,去掉注释,再把简单的注释掉就可以了。
$citycode = mb_convert_encoding($city,"gb2312","utf-8");
$doc = new DOMDocument();if (load("http://php.weather.sina.com.cn/xml.php?city=" . $citycode . "&password=DJOYnieT8234jlsK&day=0")) { echo "Get data Failed!!\n"; return;}
$city = $doc->getElementsByTagName("city")->item(0)->nodeValue;$stat1 = $doc->getElementsByTagName("status1")->item(0)->nodeValue;$chy_shuoming = $doc->getElementsByTagName("chy_shuoming")->item(0)->nodeValue;$tmp1 = $doc->getElementsByTagName("temperature1")->item(0)->nodeValue;$tmp2 = $doc->getElementsByTagName("temperature2")->item(0)->nodeValue;$date = $doc->getElementsByTagName("savedate_weather")->item(0)->nodeValue;$pollution_l = $doc->getElementsByTagName("pollution_l")->item(0)->nodeValue;$gm_s = $doc->getElementsByTagName("gm_s")->item(0)->nodeValue;
echo '