自动获取城市和IP以及天气

http://air.hkitechplus.org/city.htm 示例获取ip和城市

View Code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
<iframe src="http://m.weather.com.cn/m/pn6/weather.htm "  width="140" height="20" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>
</body>
</html>


 

http://air.hkitechplus.org/weather.htm 获取城市以及天气

View Code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script language="javascript" type="text/javascript" src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
    <script type="text/javascript">document.write("您的IP:"+ returnCitySN.cip+"<br/>您所在城市:"+returnCitySN.cname)</script>
</head>
<body>
</body>
</html>

 

实例是使用搜狐IP地址查询接口~
新浪的IP地址查询接口:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js

新浪多地域测试方法:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=218.192.3.42

搜狐IP地址查询接口(默认GBK):http://pv.sohu.com/cityjson

搜狐IP地址查询接口(可设置编码):http://pv.sohu.com/cityjson?ie=utf-8

posted @ 2012-09-26 08:24  夜照亮了黑  阅读(580)  评论(0)    收藏  举报