纯JS版的天气预报及接口代码
jsp天气预报查询课程设计
jsp天气预报查询课程设计一、课程目标知识目标:1. 学生能够理解JSP技术的基本原理和网页开发流程。
2. 学生能够掌握如何在JSP页面中嵌入Java代码,实现动态数据展示。
3. 学生能够学习并运用数据库连接和SQL查询,实现天气预报信息的调用与展示。
4. 学生了解Web服务器的基本配置和使用方法。
技能目标:1. 学生能够运用HTML、CSS和JavaScript等技术,设计并实现具有良好交互性的Web界面。
2. 学生能够通过JSP和Java语言编写程序,实现天气预报的查询和显示功能。
3. 学生能够使用数据库存储和管理数据,实现天气预报信息的更新与维护。
4. 学生能够运用所学知识解决实际项目中遇到的问题,提高项目实践能力。
情感态度价值观目标:1. 学生培养对编程和网络技术的兴趣,提高主动学习和探究的精神。
2. 学生培养团队协作意识,学会在项目开发中与他人沟通与协作。
3. 学生提高问题解决能力,增强自信心,培养勇于克服困难的品质。
4. 学生认识到编程技术在现实生活中的应用价值,激发对科技创新的热情。
课程性质:本课程为信息技术课程,以项目实践为主要教学方式,结合理论讲解,让学生在实际操作中掌握JSP技术。
学生特点:学生具备一定的Java基础,了解Web开发基本概念,但对JSP技术及其在实际项目中的应用尚不熟悉。
教学要求:结合学生特点,注重实践操作,鼓励学生动手实践,培养其编程思维和项目实践能力。
在教学过程中,关注学生个体差异,提供个性化指导,确保每个学生都能在课程中取得进步。
二、教学内容1. JSP技术原理及基本概念:介绍JSP技术的工作原理,理解JSP的生命周期,掌握JSP的内置对象及其作用。
- 相关教材章节:第3章 JSP技术基础2. Web服务器配置与使用:学习如何配置Web服务器,如Tomcat,并了解其基本操作。
- 相关教材章节:第2章 Web服务器与应用服务器3. HTML、CSS和JavaScript基础:复习Web开发基本技术,为后续页面设计打下基础。
天气预报及代码
天气预报及代码天气预报及代码点击地图上的地区,可看天气预报,喜欢的朋友可分享。
可放在首页装扮博客用,当然,也可放到日志等网页中。
第一种样式点地区,看预报(分享代码处)代码如下:<TABLE border=0 cellSpacing=0 cellPadding=0width=400 bgColor=#bbccffalign=center><TBODY><TR><TD><CE NTER><EMBED height=345type=application/x-shockwave-flashpluginspage=/go/getflashplay er width=454src=/deco/2009/1224/chin a.swf allowNetworking="internal"allowScriptAccess="never" invokeurls="false"wmode="transparent"></CENTER><CENTER><A target="_blank"href="/blog/static/1021130 7720140161293412/"><IMG title="点击分享代码"alt="点击分享代码"src="/DownloadImg/2015/06/0 108/54275104_2.jpg"httpyyygggblogcom><STRONG><FONTcolor="#ff0000" size="2">点地区,看预报(<FONT color="#3344ff">分享代码处</FONT>)</FONT></STRONG></A>< ;/CENTER></TD></TR></TABLE>注:大小可以调整(只调整代码中的高度数值345和宽度数值454即可)。
微信小程序天气预报开发实例代码源码
微信⼩程序天⽓预报开发实例代码源码微信⼩程序天⽓预报实例主要功能1. ⾃动定位所在城市2. 根据所定位的城市获取天⽓信息3. 显⽰未来⼏天的天⽓情况4. 查看当天天⽓的详情信息先看效果图微信⼩程序-天⽓⾸页微信⼩程序-天⽓详情页思路及编码部份⾃动定位所在城市wx.getLocation:通过官⽅⽂档的API中可以看到wx.getLocation可以获取到当前的地理位置和速度,不过获取到的地理位置只是经纬度,⽽不是真正的城市名称,但我们可以根据这个经纬度来获取城市名称等信息(需要⽤到第三⽅接⼝),再通过城市名称和城市ID获取对应的天⽓信息。
在.js逻辑层增加函数:data:{weatherApikey:'', //天⽓apikey,在 上申请city:'', //城市名称areaid:'', //城市对应的idcurWd:{}, //当天天⽓情况indexs:{}, //当天天⽓详情说明forecast:{} //未来4天的天⽓情况},onLoad:function(options){// ⽣命周期函数--监听页⾯加载this.setData({weatherApikey:getApp().globalData.weatherApikey});this.loadLocation();},//获取当前的位置信息,即经纬度loadLocation: function() {var page = this;wx.getLocation({type: 'gcj02', // 默认为 wgs84 返回 gps 坐标,gcj02 返回可⽤于 wx.openLocation 的坐标success: function(res){// successvar latitude = titude;var longitude = res.longitude;//获取城市page.loadCity(latitude, longitude);}})},//通过经纬度获取城市loadCity: function(latitude, longitude) {var page = this;//这个key是⾃⼰在上申请的var key = "XSWBZ-EVQ3V-UMLPA-U4TP6-6MQFZ-UUFSL";var url = "/ws/geocoder/v1/?location="+latitude+","+longitude+"&key="+key+"&get_poi=1";wx.request({url: url,data: {},method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT// header: {}, // 设置请求的 headersuccess: function(res){// successvar city = res.data.result.address_component.city;city = city.replace("市", ""); //将“市”去掉,要不然取不了天⽓信息page.setData({city: city});page.loadId(city);}})},//通过城市名称获取城市的唯⼀IDloadId: function(city) {var page = this;var url = "/apistore/weatherservice/citylist";wx.request({url: url,data: {cityname: city},header: {apikey:page.data.weatherApikey},method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECTsuccess: function(res){// successvar cityid = res.data.retData[0].area_id;page.setData({areaid: cityid});page.loadWeather(city, cityid);}})},//通过城市名称和城市ID获取天⽓情况loadWeather: function(city, areaId) {var page = this;var url = "/apistore/weatherservice/recentweathers";wx.request({url: url,data: {cityname:city,cityid: areaId},header: {apikey: page.data.weatherApikey},method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECTsuccess: function(res){// successpage.setData({curWd : res.data.retData.today, indexs: res.data.retData.today.index, forecast:res.data.retData.forecast});}})},//事件绑定,跳转到天⽓详情页⾯gotoDetail: function(event) {// console.log(this.data.areaid+"==在这⾥跳转=="+this.data.city);wx.navigateTo({url: '../detail/detail?city='+this.data.city+"&cityid="+this.data.areaid})}注意:page.setData或this.setData都是⽤来设置data中的数据值的。
中国天气预报代码大全
中国天气预报代码大全阿巴嘎旗 CHXX0243 阿城 CHXX0001爱辉CHXX0174阿合奇 CHXX0210阿拉尔 CHXX0212 阿勒泰 CHXX0196安达CHXX0187敖汉旗 CHXX0002安康CHXX0394 安宁CHXX0003 安庆CHXX0452鞍山 CHXX0004安顺CHXX0005 安阳CHXX0269 安县CHXX0182 巴楚 CHXX0211百灵庙CHXX0247 班戈CHXX0324 百色CHXX0488 白银 CHXX0006巴仑台CHXX0204 保定CHXX0308 宝鸡CHXX0387 宝清 CHXX0188保山CHXX0370 包头CHXX0007 巴中CHXX0348 巴塘 CHXX0352巴音毛道 CHXX0225 巴音布鲁克 CHXX0206 北塔山 CHXX0201北海CHXX0499 北京CHXX0008 蚌埠CHXX0444 本溪 CHXX0296毕节CHXX0418 彬县CHXX0439 波阳CHXX0009 博克图 CHXX0287长岛CHXX0312 长白CHXX0299 长春CHXX0010 常德 CHXX0416昌吉CHXX0011 长岭CHXX0277 长平CHXX0012 长沙 CHXX0013常熟CHXX0014 长汀CHXX0472 常州CHXX0015 朝阳 CHXX0294承德CHXX0302 成都CHXX0016 成山头CHXX0314 郴州 CHXX0435赤峰CHXX0286 重庆CHXX0017 楚雄CHXX0373 达县 CHXX0400大柴旦 CHXX0230 大陈岛 CHXX0464 达拉特旗 CHXX0018 大理 CHXX0371大连CHXX0019 丹东CHXX0306 单县CHXX0505 稻城 CHXX0357Daodi CHXX0020 Daolin CHXX0021 Darlag CHXX0336 大同 CHXX0251大通CHXX0022 大悟CHXX0347 大兴CHXX0023 德格 CHXX0344德令哈 CHXX0231 丁青 CHXX0342 堆龙德庆 CHXX0360 定海 CHXX0455定陶CHXX0320 定西CHXX0024 定县CHXX0025 东方 CHXX0504东沙岛CHXX0503 东升CHXX0255 东台CHXX0445 都兰 CHXX0235敦化CHXX0284 敦煌CHXX0223 多伦CHXX0285 独山 CHXX0432伊金霍洛旗CHXX0220 峨眉山CHXX0359 恩施 CHXX0406二连浩特 CHXX0240 房县 CHXX0395 凤城CHXX0026 奉节 CHXX0401丰宁CHXX0292 丰台CHXX0027 佛冈CHXX0483 佛山 CHXX0028扶绥CHXX0030 福鼎CHXX0469 富锦CHXX0185 抚顺 CHXX0029阜阳(富阳) CHXX0442 富蕴 CHXX0197 福州CHXX0031 刚察 CHXX0232甘谷CHXX0032 赣榆CHXX0438 赣州CHXX0436 高要 CHXX0491高邑CHXX0033 甘孜CHXX0345 耿马CHXX0377 格尔木 CHXX0234贡嚘CHXX0034 珙县CHXX0035 拐子湖CHXX0222 广安 CHXX0036广昌CHXX0470 广华CHXX0396 广南CHXX0477 广州 CHXX0037贵定CHXX0038 桂林CHXX0434 桂平CHXX0489 贵阳 CHXX0039固始CHXX0443 固阳CHXX0040 海城CHXX0041 海口 CHXX0502海拉尔CHXX0175 海林CHXX0244 海伦CHXX0183 海宁 CHXX0042海晏CHXX0319 Haliut CHXX0246 哈密CHXX0219 汉沽 CHXX0043杭州CHXX0044 汉江CHXX0045 汉中CHXX0390 哈尔滨 CHXX0046河池CHXX0478 合川CHXX0047 合肥CHXX0448 合江 CHXX0048河南CHXX0337 河曲CHXX0256 河源CHXX0492 菏泽 CHXX0339和布克塞尔 CHXX0199 呼和浩特 CHXX0249 香港 CHXX0049和田CHXX0216 华山CHXX0388 淮阳CHXX0052 化德 CHXX0248桦甸CHXX0290 怀来CHXX0301 华家岭CHXX0239 黄山 CHXX0453黄陂CHXX0050 黄石CHXX0051会理CHXX0366 惠民 CHXX0311会泽CHXX0367 惠州CHXX0053 呼兰CHXX0054 虎林 CHXX0194呼玛CHXX0172 霍山CHXX0447 胡四台CHXX0055 湖州 CHXX0056吉兰太 CHXX0252 扎鲁特旗 CHXX0275 集安 CHXX0425 江城 CHXX0384江津CHXX0057 江陵CHXX0408 江门CHXX0058 建阳 CHXX0059胶南CHXX0060 焦县CHXX0061 嘉兴CHXX0062 介休 CHXX0268吉林CHXX0063 济南CHXX0064 景德镇CHXX0457 静海 CHXX0065精河CHXX0202 景洪CHXX0380 靖远CHXX0066 济宁 CHXX0250锦州CHXX0067 九江CHXX0068 九龙CHXX0361 酒泉 CHXX0226九台CHXX0069 九仙山CHXX0475 久镇CHXX0070 鸡西 CHXX0193朱日和 CHXX0245 句容 CHXX0071 哈巴河CHXX0195 开封 CHXX0072开阳 CHXX0073 康定 CHXX0358 克拉玛依CHXX0200 喀什 CHXX0074克山 CHXX0181 King's Park CHXX0170 库尔勒 CHXX0209库伦旗CHXX0075 宽甸CHXX0305 昆明CHXX0076 昆阳 CHXX0077库车CHXX0208 澜沧CHXX0379 阆中CHXX0399 兰西 CHXX0078兰州CHXX0079 冷湖CHXX0227 乐亭CHXX0307 拉萨 CHXX0080乐至CHXX0329 连县CHXX0481 梁平CHXX0405 连平 CHXX0484辽阳CHXX0081 利津CHXX0365 临沧CHXX0378 临东 CHXX0276零陵CHXX0429 陵县CHXX0310 临海CHXX0463 临河 CHXX0253临江CHXX0297 临潼CHXX0082 林西CHXX0281 灵石 CHXX0264丽水CHXX0461 理塘CHXX0353 浏阳CHXX0083 柳州 CHXX0479溧阳CHXX0450 龙口CHXX0313 龙里CHXX0084 龙州 CHXX0494庐山CHXX0456 漯河CHXX0085 罗甸CHXX0431 洛阳 CHXX0086卢氏CHXX0389 泸水CHXX0087 吕泗CHXX0446 泸溪 CHXX0376泸州CHXX0088 澳门CHXX0512 麻城CHXX0403 玛多 CHXX0335玛纳斯 CHXX0089 满都拉 CHXX0242 茫崖CHXX0217 茂名 CHXX0090马鬃山CHXX0221 梅县CHXX0486 眉山CHXX0091 勐腊 CHXX0383蒙山CHXX0480 孟州CHXX0092 蒙自CHXX0385 绵阳 CHXX0351民和CHXX0093 民勤CHXX0229 闽清CHXX0094 米泉 CHXX0095密云CHXX0096 漠河CHXX0171 牡丹江CHXX0278 那曲 CHXX0325南昌CHXX0097 南城CHXX0465 南充CHXX0098 南京 CHXX0099南宁CHXX0100 南平CHXX0471 南沙岛CHXX0511 南通 CHXX0101南县CHXX0102 南阳CHXX0391 南岳CHXX0423 那坡 CHXX0487那仁宝力格 CHXX0241 内江 CHXX0103 嫩江 CHXX0177New Kowloon CHXX0104 牛庄CHXX0105 Nyingchi CHXX0356鄂托克旗 CHXX0254 帕里 CHXX0330 平凉CHXX0270平潭CHXX0476 平武CHXX0350 平遥CHXX0106 平阴 CHXX0107皮山CHXX0215 勃力CHXX0108 泊头CHXX0309 蒲城 CHXX0468蒲口 CHXX0109 恰卜恰 CHXX0343 前郭尔罗斯 CHXX0190Qijiaojing CHXX0205 青岛 CHXX0110 清江CHXX0111 青龙 CHXX0303清远CHXX0289 钦州CHXX0498 琼海CHXX0506 齐齐哈尔 CHXX0112奇台CHXX0113 渠县CHXX0460 泉州CHXX0114 曲麻莱 CHXX0333日照CHXX0322 榕江CHXX0433 瑞丽CHXX0375 若尔盖 CHXX0338若羌CHXX0214 桑植CHXX0410 珊瑚岛CHXX0509 三水 CHXX0426色达CHXX0346 上蔡CHXX0115 上川岛CHXX0501 上海 CHXX0116尚志CHXX0192 汕头CHXX0493 汕尾CHXX0496 韶关 CHXX0482邵武CHXX0466 绍兴CHXX0117 邵阳CHXX0422 沙市 CHXX0118嵊泗CHXX0454 深县CHXX0458 沈阳CHXX0119 深圳 CHXX0120射阳CHXX0441 石拐CHXX0121 石家庄CHXX0122 石楼 CHXX0123石浦CHXX0459 狮泉河CHXX0323 双城CHXX0124 沭阳 CHXX0125思茅CHXX0381 思南CHXX0420 四平CHXX0283 索县 CHXX0341松潘 CHXX0349 石炭井 CHXX0126 绥芬河CHXX0279 绥宁 CHXX0127孙吴CHXX0178 塔城CHXX0198 塔河CHXX0128 泰山 CHXX0316泰来CHXX0186 太原CHXX0129 塘沽CHXX0130 唐山 CHXX0131腾冲CHXX0369 天冈CHXX0132 天津CHXX0133 天水 CHXX0386铁岭 CHXX0134 铁干里克 CHXX0213 铁力CHXX0328 通道 CHXX0427通河CHXX0191 通辽CHXX0282 图里河CHXX0173 托托河 CHXX0331吐鲁番CHXX0207 Uliastai CHXX0189 。
调用第三方接口开发案例
以下是一个调用第三方接口的开发案例:
假设我们要开发一个天气查询的应用,我们可以调用一个天气数据的第三方接口来获取天气信息。
首先,我们需要注册并获取一个天气数据的第三方接口的API密钥。
然后,我们可以使用HTTP请求库(如Python的requests库)来发送HTTP请求并获取响应。
接下来,我们可以编写一个函数来调用天气数据的第三方接口。
函数的输入参数可以是城市名或经纬度,输出参数可以是天气信息(如温度、湿度、风力等)。
在函数内部,我们可以构造一个HTTP请求,包括URL、请求方法(GET或POST)、请求头(包括API密钥)、请求参数(城市名或经纬度)等。
然后,我们可以发送HTTP请求并获取响应。
最后,我们可以解析响应数据,提取出我们需要的天气信息,并返回给调用者。
这样,我们就可以在我们的应用中调用这个函数来获取天气
信息,并展示给用户。
需要注意的是,调用第三方接口时,我们需要遵守接口提供方的使用规则和限制,如请求频率限制、数据使用限制等。
同时,我们也需要处理接口调用失败的情况,如网络连接失败、接口返回错误等。
j2me 代码 天气预报
view plaincopy to clipboardprint?01.package googleweather;02.03.import java.io.ByteArrayOutputStream;04.import java.io.DataInputStream;05.import java.io.IOException;06.import java.io.InputStream;07.import java.io.InputStreamReader;08.09.import javax.microedition.io.Connector;10.import javax.microedition.io.HttpConnection;11.import javax.microedition.lcdui.CustomItem;12.import javax.microedition.lcdui.Display;13.import javax.microedition.lcdui.Form;14.import javax.microedition.lcdui.Graphics;15.import javax.microedition.lcdui.Image;16.import javax.microedition.midlet.MIDlet;17.import javax.microedition.midlet.MIDletStateChangeException;18.19.import org.kxml2.io.KXmlParser;20.import org.xmlpull.v1.XmlPullParserException;21.22.public class GoogleWeather extends MIDlet {23. InputStream is;24. Display dis;25. Form f;26. int width ;27. String city ;28. String forecast_date;29. public GoogleWeather() {30. dis = Display.getDisplay(this);31.32. }33.34. protected void destroyApp(boolean arg0) throws MIDletStateChangeException {35. // TODO Auto-generated method stub36.37. }38.39. protected void pauseApp() {40. // TODO Auto-generated method stub41.42. }43.44. protected void startApp() throws MIDletStateChangeException {45. f = new Form("天气预报");46. width = f.getWidth();47. dis.setCurrent(f);48. getIS() ;49. if (is == null) f.append("is == null");50. parse();51. }52.53. public boolean getIS() {54. String url = "/ig/api?weather=Shanghai";55. HttpConnection hcon = null;56. boolean ret = false;57. try {58. hcon = (HttpConnection) Connector.open(url);59. String contentType = hcon.getHeaderField("Content-Type"); // 这里用来过滤移动资费页面60. if (contentType != null61. && contentType.indexOf("text/vnd.wap.wml") != -1) {62. hcon = null;63. hcon = (HttpConnection) Connector.open(url);64. }65. is = new DataInputStream(hcon.openInputStream());66. ret = true;67. } catch (Exception e) {68. ret = false;69. e.printStackTrace();70. }71. return ret;72. }73.74. public boolean parse() {75. KXmlParser parser;76. parser = new KXmlParser();77. boolean ret = false;78. try {79. parser.setInput(new InputStreamReader(is));80. xml_api_reply(parser);81.82. } catch (Exception e) {83. e.printStackTrace();84. }85. try {86. is.close();87. } catch (IOException e) {88. e.printStackTrace();89. }90. return ret;91. }92.93. private void xml_api_reply(KXmlParser parser) {94. try {95.96. parser.nextT ag();97. parser.require(KXmlParser.START_TAG, null, "xml_api_reply");98. parser.nextT ag();99. parser.require(KXmlParser.START_TAG, null, "weather");100. parser.nextT ag();101. forecast_information(parser);102. parser.nextT ag();103. current_conditions(parser);104. parser.nextT ag();105. forecast_conditions(parser);106. parser.nextT ag();107. forecast_conditions(parser);108. parser.nextT ag();109. forecast_conditions(parser);110. parser.nextT ag();111. forecast_conditions(parser);112. parser.nextT ag();113. parser.require(KXmlParser.END_TAG, null, "weather");114. parser.nextT ag();115. parser.require(KXmlParser.END_TAG, null, "xml_api_reply");116. } catch (XmlPullParserException e) {117. f.append("11");118. } catch (IOException e) {119. f.append("12");120. }121. }122.123. private void current_conditions(KXmlParser parser) throws XmlPullParserException, IOException {124.125. String condition,temp_f,temp_c ,humidity ,icon,wind_condition ;126. parser.require(KXmlParser.START_TAG, null, "current_conditions");127. parser.nextT ag();128. parser.require(KXmlParser.START_TAG, null, "condition");129. condition = parser.getAttributeValue(0);130. parser.nextT ag();131. parser.require(KXmlParser.END_TAG, null, "condition");132.133. parser.nextT ag();134. parser.require(KXmlParser.START_TAG, null, "temp_f");135. temp_f = parser.getAttributeValue(0);136. parser.nextT ag();137. parser.require(KXmlParser.END_TAG, null, "temp_f");138.139. parser.nextT ag();140. parser.require(KXmlParser.START_TAG, null, "temp_c");141. temp_c = parser.getAttributeValue(0);142. parser.nextT ag();143. parser.require(KXmlParser.END_TAG, null, "temp_c");144. parser.nextT ag();145. parser.require(KXmlParser.START_TAG, null, "humidity");146. humidity = parser.getAttributeValue(0);147. parser.nextT ag();148. parser.require(KXmlParser.END_TAG, null, "humidity");149. parser.nextT ag();150. parser.require(KXmlParser.START_TAG, null, "icon");151. icon = parser.getAttributeValue(0);152. parser.nextT ag();153. parser.require(KXmlParser.END_TAG, null, "icon");154. parser.nextT ag();155. parser.require(KXmlParser.START_TAG, null, "wind_condition");156. wind_condition = parser.getAttributeValue(0);157. parser.nextT ag();158. parser.require(KXmlParser.END_TAG, null, "wind_condition");159. parser.nextT ag();160.161.162. System.out.println(condition);163. System.out.println(temp_f);164. System.out.println(temp_c);165. System.out.println(humidity);166. System.out.println(icon);167. System.out.println(wind_condition);168.169. icon = "" + icon ;170.171. CurrentWeatherItem cwi = new CurrentWeatherItem(temp_c , city , forecast_date, loadHttpFile(icon));172. f.append(cwi);173. parser.require(KXmlParser.END_TAG, null, "current_conditions");174.175. }176.177. private Image loadHttpFile(String url) throws IOException {178.179. System.out.println(url);180. byte[] byteBuffer = null;181. HttpConnection hc = (HttpConnection) Connector.open(url);182. String contentType = hc.getHeaderField("Content-Type"); // 这里用来过滤移动资费页面183. if (contentType != null184. && contentType.indexOf("text/vnd.wap.wml") != -1) {185. hc = null;186. hc = (HttpConnection) Connector.open(url);187. }188. int code = hc.getResponseCode();189. if (code == 200) {190. try {191. InputStream is = hc.openInputStream();192. try {193. int len = (int) hc.getLength();194. if (len > 0) {195. byteBuffer = new byte[len];196. int done = 0;197. while (done < len) {198. done += is.read(byteBuffer, done, len - done);199. }200. } else {201. ByteArrayOutputStream bos = new ByteArrayOutputStream(); 202. byte[] buffer = new byte[512];203. int count;204. while ((count = is.read(buffer)) >= 0) {205. bos.write(buffer, 0, count);206. }207. byteBuffer = bos.toByteArray();208. }209. } finally {210. is.close();211. }212. } finally {213. hc.close();214. }215. }216. return Image.createImage(byteBuffer, 0, byteBuffer.length);217.218. }219.220. private void forecast_information(KXmlParser parser) throws XmlPullParserException, IOException {221. String city,postal_code,latitude_e6,longitude_e6,forecast_date,current_date_time,unit_system; 222. parser.require(KXmlParser.START_TAG, null, "forecast_information");223. parser.nextT ag();224. parser.require(KXmlParser.START_TAG, null, "city");225. city = parser.getAttributeValue(0);226. parser.nextT ag();227. parser.require(KXmlParser.END_TAG, null, "city");228. parser.nextT ag();229. parser.require(KXmlParser.START_TAG, null, "postal_code");230. postal_code = parser.getAttributeValue(0);231. parser.nextT ag();232. parser.require(KXmlParser.END_TAG, null, "postal_code");233. parser.nextT ag();234. parser.require(KXmlParser.START_TAG, null, "latitude_e6");235. latitude_e6 = parser.getAttributeValue(0);236. parser.nextT ag();237. parser.require(KXmlParser.END_TAG, null, "latitude_e6");238. parser.nextT ag();239. parser.require(KXmlParser.START_TAG, null, "longitude_e6");240. longitude_e6 = parser.getAttributeValue(0);241. parser.nextT ag();242. parser.require(KXmlParser.END_TAG, null, "longitude_e6");243. parser.nextT ag();244. parser.require(KXmlParser.START_TAG, null, "forecast_date");245. forecast_date = parser.getAttributeValue(0);246. parser.nextT ag();247. parser.require(KXmlParser.END_TAG, null, "forecast_date");248. parser.nextT ag();249. parser.require(KXmlParser.START_TAG, null, "current_date_time");250. current_date_time = parser.getAttributeValue(0);251. parser.nextT ag();252. parser.require(KXmlParser.END_TAG, null, "current_date_time");253. parser.nextT ag();254. parser.require(KXmlParser.START_TAG, null, "unit_system");255. unit_system = parser.getAttributeValue(0);256. parser.nextT ag();257. parser.require(KXmlParser.END_TAG, null, "unit_system");258. parser.nextT ag();259.260. System.out.println(city);261. System.out.println(postal_code);262. System.out.println(latitude_e6);263. System.out.println(longitude_e6);264. System.out.println(forecast_date);265. System.out.println(current_date_time);266. System.out.println(unit_system);267.268. this.city = city ;269. this.forecast_date = forecast_date ;270. parser.require(KXmlParser.END_TAG, null, "forecast_information");271.272. }273.274. private void forecast_conditions(KXmlParser parser) throws XmlPullParserException, IOException {275.276. String day_of_week,low,high,icon ,condition ;277. parser.require(KXmlParser.START_TAG, null, "forecast_conditions");278. parser.nextT ag();279. parser.require(KXmlParser.START_TAG, null, "day_of_week");280. day_of_week = parser.getAttributeValue(0);281. parser.nextT ag();282. parser.require(KXmlParser.END_TAG, null, "day_of_week");283.284. parser.nextT ag();285. parser.require(KXmlParser.START_TAG, null, "low");286. low = parser.getAttributeValue(0);287. parser.nextT ag();288. parser.require(KXmlParser.END_TAG, null, "low");289.290. parser.nextT ag();291. parser.require(KXmlParser.START_TAG, null, "high");292. high = parser.getAttributeValue(0);293. parser.nextT ag();294. parser.require(KXmlParser.END_TAG, null, "high");295. parser.nextT ag();296. parser.require(KXmlParser.START_TAG, null, "icon");297. icon = parser.getAttributeValue(0);298. parser.nextT ag();299. parser.require(KXmlParser.END_TAG, null, "icon");300. parser.nextT ag();301. parser.require(KXmlParser.START_TAG, null, "condition");302. condition = parser.getAttributeValue(0);303. parser.nextT ag();304. parser.require(KXmlParser.END_TAG, null, "condition");305. parser.nextT ag();306.307. System.out.println(day_of_week);308. System.out.println(low);309. System.out.println(high);310. System.out.println(icon);311. System.out.println(condition);312. icon = "" + icon ;313.314. if(day_of_week.equalsIgnoreCase("mon")) day_of_week = "周一" ;315. else if(day_of_week.equalsIgnoreCase("tue")) day_of_week = "周二";316. else if(day_of_week.equalsIgnoreCase("wed")) day_of_week = "周三";317. else if(day_of_week.equalsIgnoreCase("thu")) day_of_week = "周四";318. else if(day_of_week.equalsIgnoreCase("fri")) day_of_week = "周五";319. else if(day_of_week.equalsIgnoreCase("sat")) day_of_week = "周六";320. else day_of_week = "周日";321. low = String.valueOf((Integer.parseInt(low) - 32) * 5 / 9);322. high = String.valueOf((Integer.parseInt(high) - 32) * 5 / 9);323.324. ForecastWeatherItem fwi = new ForecastWeatherItem(day_of_week, low , high , loadHttpFile(icon));325. f.append(fwi);326. parser.require(KXmlParser.END_TAG, null, "forecast_conditions");327. }328.329. public class CurrentWeatherItem extends CustomItem{330.331. String temp ;332. String city ;333. String forecast_date;334. Image icon;335. protected CurrentWeatherItem(String temp , String city ,String forecast_date,Image icon ) {336. super(forecast_date);337. this.temp = temp ;338. this.city = city;339. this.forecast_date = forecast_date;340. this.icon = icon;341. }342.343. protected int getMinContentHeight() {344. // TODO Auto-generated method stub345. return 40;346. }347.348. protected int getMinContentWidth() {349. // TODO Auto-generated method stub350. return width;351. }352.353. protected int getPrefContentHeight(int arg0) {354. // TODO Auto-generated method stub355. return 40;356. }357.358. protected int getPrefContentWidth(int arg0) {359. // TODO Auto-generated method stub360. return width;361. }362.363. protected void paint(Graphics g, int arg1, int arg2) {364. g.setColor(0x9accff);365. g.fillRect(0, 0, width, 40);366. g.drawImage(this.icon, 20, 20, Graphics.HCENTER | Graphics.VCENTER); 367. g.setColor(0x000000);368. g.drawString("当前气温:" , 50, 10, 0);369. g.drawString(temp + "℃" , 100, 10, 0);370. }371. }372.373. public class ForecastWeatherItem extends CustomItem{374.375. String day_of_week;376. String low;377. String high ;378. Image icon;379. protected ForecastWeatherItem(String day_of_week, String low, String high , Image icon) {380. super(null);381. this.day_of_week = day_of_week;382. this.low = low;383. this.high = high ;384. this.icon = icon ;385. }386.387. protected int getMinContentHeight() {388. // TODO Auto-generated method stub389. return 40;390. }391.392. protected int getMinContentWidth() {393. // TODO Auto-generated method stub394. return width;395. }396.397. protected int getPrefContentHeight(int arg0) {398. // TODO Auto-generated method stub399. return 40;400. }401.402. protected int getPrefContentWidth(int arg0) {403. // TODO Auto-generated method stub404. return width;405. }406.407. protected void paint(Graphics g, int arg1, int arg2) {408. g.setColor(0x66cbff);409. g.fillRect(0, 0, width, 40);410. g.drawImage(this.icon, 20, 20, Graphics.HCENTER | Graphics.VCENTER); 411. g.setColor(0x000000);412. g.drawString(day_of_week , 50, 10, 0);413. g.drawString(low + "℃/" + high + "℃", 100, 10, 0);414. }415. }416.}package googleweather;import java.io.ByteArrayOutputStream;import java.io.DataInputStream;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import javax.microedition.io.Connector;import javax.microedition.io.HttpConnection;import javax.microedition.lcdui.CustomItem;import javax.microedition.lcdui.Display;import javax.microedition.lcdui.Form;import javax.microedition.lcdui.Graphics;import javax.microedition.lcdui.Image;import javax.microedition.midlet.MIDlet;import javax.microedition.midlet.MIDletStateChangeException;import org.kxml2.io.KXmlParser;import org.xmlpull.v1.XmlPullParserException;public class GoogleWeather extends MIDlet {InputStream is;Display dis;Form f;int width ;String city ;String forecast_date;public GoogleWeather() {dis = Display.getDisplay(this);}protected void destroyApp(boolean arg0) throws MIDletStateChangeException { // TODO Auto-generated method stub}protected void pauseApp() {// TODO Auto-generated method stub}protected void startApp() throws MIDletStateChangeException {f = new Form("天气预报");width = f.getWidth();dis.setCurrent(f);getIS() ;if (is == null) f.append("is == null");parse();}public boolean getIS() {String url = "/ig/api?weather=Shanghai";HttpConnection hcon = null;boolean ret = false;try {hcon = (HttpConnection) Connector.open(url);String contentType = hcon.getHeaderField("Content-Type"); // 这里用来过滤移动资费页面if (contentType != null&& contentType.indexOf("text/vnd.wap.wml") != -1) {hcon = null;hcon = (HttpConnection) Connector.open(url);}is = new DataInputStream(hcon.openInputStream());ret = true;} catch (Exception e) {ret = false;e.printStackTrace();}return ret;}public boolean parse() {KXmlParser parser;parser = new KXmlParser();boolean ret = false;try {parser.setInput(new InputStreamReader(is));xml_api_reply(parser);} catch (Exception e) {e.printStackTrace();}try {is.close();} catch (IOException e) {e.printStackTrace();}return ret;}private void xml_api_reply(KXmlParser parser) {try {parser.nextTag();parser.require(KXmlParser.START_TAG, null, "xml_api_reply");parser.nextTag();parser.require(KXmlParser.START_TAG, null, "weather");parser.nextTag();forecast_information(parser);parser.nextTag();current_conditions(parser);parser.nextTag();forecast_conditions(parser);parser.nextTag();forecast_conditions(parser);parser.nextTag();forecast_conditions(parser);parser.nextTag();forecast_conditions(parser);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "weather");parser.nextTag();parser.require(KXmlParser.END_TAG, null, "xml_api_reply");} catch (XmlPullParserException e) {f.append("11");} catch (IOException e) {f.append("12");}}private void current_conditions(KXmlParser parser) throws XmlPullParserException, IOException {String condition,temp_f,temp_c ,humidity ,icon,wind_condition ;parser.require(KXmlParser.START_TAG, null, "current_conditions");parser.nextTag();parser.require(KXmlParser.START_TAG, null, "condition");condition = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "condition");parser.nextTag();parser.require(KXmlParser.START_TAG, null, "temp_f");temp_f = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "temp_f");parser.nextTag();parser.require(KXmlParser.START_TAG, null, "temp_c");temp_c = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "temp_c");parser.nextTag();parser.require(KXmlParser.START_TAG, null, "humidity");humidity = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "humidity");parser.nextTag();parser.require(KXmlParser.START_TAG, null, "icon");icon = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "icon");parser.nextTag();parser.require(KXmlParser.START_TAG, null, "wind_condition");wind_condition = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "wind_condition");parser.nextTag();System.out.println(condition);System.out.println(temp_f);System.out.println(temp_c);System.out.println(humidity);System.out.println(icon);System.out.println(wind_condition);icon = "" + icon ;CurrentWeatherItem cwi = new CurrentWeatherItem(temp_c , city , forecast_date, loadHttpFile(icon));f.append(cwi);parser.require(KXmlParser.END_TAG, null, "current_conditions");}private Image loadHttpFile(String url) throws IOException {System.out.println(url);byte[] byteBuffer = null;HttpConnection hc = (HttpConnection) Connector.open(url);String contentType = hc.getHeaderField("Content-Type"); // 这里用来过滤移动资费页面if (contentType != null&& contentType.indexOf("text/vnd.wap.wml") != -1) {hc = null;hc = (HttpConnection) Connector.open(url);}int code = hc.getResponseCode();if (code == 200) {try {InputStream is = hc.openInputStream();try {int len = (int) hc.getLength();if (len > 0) {byteBuffer = new byte[len];int done = 0;while (done < len) {done += is.read(byteBuffer, done, len - done);}} else {ByteArrayOutputStream bos = new ByteArrayOutputStream();byte[] buffer = new byte[512];int count;while ((count = is.read(buffer)) >= 0) {bos.write(buffer, 0, count);}byteBuffer = bos.toByteArray();}} finally {is.close();}} finally {hc.close();}}return Image.createImage(byteBuffer, 0, byteBuffer.length);}private void forecast_information(KXmlParser parser) throws XmlPullParserException, IOException {Stringcity,postal_code,latitude_e6,longitude_e6,forecast_date,current_date_time,unit_system;parser.require(KXmlParser.START_TAG, null, "forecast_information");parser.nextTag();parser.require(KXmlParser.START_TAG, null, "city");city = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "city");parser.nextTag();parser.require(KXmlParser.START_TAG, null, "postal_code"); postal_code = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "postal_code"); parser.nextTag();parser.require(KXmlParser.START_TAG, null, "latitude_e6"); latitude_e6 = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "latitude_e6"); parser.nextTag();parser.require(KXmlParser.START_TAG, null, "longitude_e6"); longitude_e6 = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "longitude_e6"); parser.nextTag();parser.require(KXmlParser.START_TAG, null, "forecast_date"); forecast_date = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "forecast_date"); parser.nextTag();parser.require(KXmlParser.START_TAG, null, "current_date_time"); current_date_time = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "current_date_time"); parser.nextTag();parser.require(KXmlParser.START_TAG, null, "unit_system");unit_system = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "unit_system"); parser.nextTag();System.out.println(city);System.out.println(postal_code);System.out.println(latitude_e6);System.out.println(longitude_e6);System.out.println(forecast_date);System.out.println(current_date_time);System.out.println(unit_system);this.city = city ;this.forecast_date = forecast_date ;parser.require(KXmlParser.END_TAG, null, "forecast_information");}private void forecast_conditions(KXmlParser parser) throws XmlPullParserException, IOException {String day_of_week,low,high,icon ,condition ;parser.require(KXmlParser.START_TAG, null, "forecast_conditions");parser.nextTag();parser.require(KXmlParser.START_TAG, null, "day_of_week");day_of_week = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "day_of_week");parser.nextTag();parser.require(KXmlParser.START_TAG, null, "low");low = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "low");parser.nextTag();parser.require(KXmlParser.START_TAG, null, "high");high = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "high");parser.nextTag();parser.require(KXmlParser.START_TAG, null, "icon");icon = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "icon");parser.nextTag();parser.require(KXmlParser.START_TAG, null, "condition");condition = parser.getAttributeValue(0);parser.nextTag();parser.require(KXmlParser.END_TAG, null, "condition");parser.nextTag();System.out.println(day_of_week);System.out.println(low);System.out.println(high);System.out.println(icon);System.out.println(condition);icon = "" + icon ;if(day_of_week.equalsIgnoreCase("mon")) day_of_week = "周一" ;else if(day_of_week.equalsIgnoreCase("tue")) day_of_week = "周二";else if(day_of_week.equalsIgnoreCase("wed")) day_of_week = "周三";else if(day_of_week.equalsIgnoreCase("thu")) day_of_week = "周四";else if(day_of_week.equalsIgnoreCase("fri")) day_of_week = "周五";else if(day_of_week.equalsIgnoreCase("sat")) day_of_week = "周六";else day_of_week = "周日";low = String.valueOf((Integer.parseInt(low) - 32) * 5 / 9);high = String.valueOf((Integer.parseInt(high) - 32) * 5 / 9);ForecastWeatherItem fwi = new ForecastWeatherItem(day_of_week, low , high , loadHttpFile(icon));f.append(fwi);parser.require(KXmlParser.END_TAG, null, "forecast_conditions");}public class CurrentWeatherItem extends CustomItem{String temp ;String city ;String forecast_date;Image icon;protected CurrentWeatherItem(String temp , String city ,String forecast_date,Image icon ) {super(forecast_date);this.temp = temp ;this.city = city;this.forecast_date = forecast_date;this.icon = icon;}protected int getMinContentHeight() {// TODO Auto-generated method stubreturn 40;}protected int getMinContentWidth() {// TODO Auto-generated method stubreturn width;}protected int getPrefContentHeight(int arg0) {// TODO Auto-generated method stubreturn 40;}protected int getPrefContentWidth(int arg0) {// TODO Auto-generated method stubreturn width;}protected void paint(Graphics g, int arg1, int arg2) {g.setColor(0x9accff);g.fillRect(0, 0, width, 40);g.drawImage(this.icon, 20, 20, Graphics.HCENTER | Graphics.VCENTER);g.setColor(0x000000);g.drawString("当前气温:" , 50, 10, 0);g.drawString(temp + "℃" , 100, 10, 0);}}public class ForecastWeatherItem extends CustomItem{String day_of_week;String low;String high ;Image icon;protected ForecastWeatherItem(String day_of_week, String low, String high , Image icon) {super(null);this.day_of_week = day_of_week;this.low = low;this.high = high ;this.icon = icon ;}protected int getMinContentHeight() {// TODO Auto-generated method stubreturn 40;}protected int getMinContentWidth() {// TODO Auto-generated method stubreturn width;}protected int getPrefContentHeight(int arg0) {// TODO Auto-generated method stubreturn 40;。
完整的动态网页代码
完整的动态网页代码,图片无缝滚动代码<table width="880" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td height="115" valign="middle"><div id=demo style="OVERFLOW: hidden; WIDTH: 100%; HEIGHT: 115px"><table cellpadding=0 align=left border=1 cellspace="0" bordercolor="#ffffff"><tr bordercolor="#FFFFFF"><td id=demo11><table width='100%' cellpadding='0' cellspacing='2' border='0'><tr><td align='center'><a href="scml.asp" target="_blank"><a href='img/1.jpg'><img src='imgs/1.jpg' width='140' height='115' border="0"></a></td><td align='center'><a href="scml.asp" target="_blank"> <a href='img/2.jpg'><img src='imgs/2.jpg' width='140' height='115' border='0'></a></td><td align='center'><a target="_blank" href="scml.asp"> <a href='img/3.jpg'><img src='imgs/3.jpg' width='140' height='115' border='0'></a></td><td align='center'><a href="scml.asp" target="_blank"> <a href='img/4.jpg'><img src='imgs/4.jpg' width='140' height='115' border='0'></a></td><td align='center'><a href="scml.asp" target="_blank"> <a href='img/5.jpg'><img src='imgs/5.jpg' width='140' height='115' border='0'></a></td><td align='center'><a href="scml.asp" target="_blank"> <a href='img/6.jpg'><img src='imgs/6.jpg' width='140' height='115' border='0'></a></td></tr></table></td><td id=demo12></td></tr></table></div><SCRIPT>var speed=15demo12.innerHTML=demo11.innerHTMLfunction Marquee11(){if(demo12.offsetWidth-demo.scrollLeft<=0)demo.scrollLeft-=demo11.offsetWidthelse{demo.scrollLeft++}}var MyMar1=setInterval(Marquee11,speed)demo.onmouseover=function() {clearInterval(MyMar1)}demo.onmouseout=function() {MyMar1=setInterval(Marquee11,speed)}</SCRIPT></td></tr></table>时间代码:1<div id="jnkc"></div><script>setInterval("jnkc.innerHTML=new Date().toLocaleString()+'星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);</script></div>2<SCRIPT language=JavaScript src="js/openfullwin.js"></SCRIPT>3<div id="jnkc" class="d12"><script>setInterval("jnkc.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);</script></div>4.日期:<div id="jnkc" class="d12"><script>setInterval("jnkc.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);</script></div>5.显示日期<script language="JavaScript" type="text/javascript">today=new Date();function initArray(){this.length=initArray.arguments.lengthfor(var i=0;i<this.length;i++)this[i+1]=initArray.arguments[i] }var d=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六");document.write("<font color=red style='font-size:10pt;font-family: 宋体'> ","今天是:",today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日",d[today.getDay()+1],"</font>" );</script>天气预报的代码一、天气预报的代码:<div align="center"><iframe src=" /weather.htm" width="160" height="60"frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></div>二、天气预报的代码:<div align="center"><iframe src=" /weather.htm" width="160" height="60"frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></div>天气预报<iframe src='/weather.htm' width='168' height='50' frameborder='0' marginwidth='0' marginheight='0' scrolling='no'></iframe>新闻频道代码新闻代码<iframe border=0 name=I1 marginwidth=0marginheight=0 src="/iframe/o/allnews/input/index.htm" frameborder=No width=760 scrolling=no height=12></iframe>一.新闻糸统1.查询开始的代码<%Set rs = Server.CreateObject ("ADODB.Recordset")sql = "Select top 6 * from news order by id desc"rs.Open sql,conn,1,1%>2.循环开始代码<%if rs.EOF and rs.BOF thenresponse.write ("暂时还没有文章")elseDo Until rs.EOF%>3.循环结束代码<%rs.MoveNextLoopend if%>4.查询结束代码<%rs.closeSet rs = Nothingconn.closeset conn=Nothing%>******************************************************************************二.新闻目录1.循环开始代码<%Const MaxPerPage=18dim totalPutdim CurrentPagedim TotalPagesdim jdim sqlif Not isempty(request("page")) thencurrentPage=Cint(request("page"))elsecurrentPage=1end ifset rs=server.CreateObject("adodb.recordset")sql="select * from news order by id"rs.open sql,conn,1,1a=1if err.number<>0 thenresponse.write "数据库中无数据"end ifif rs.eof And rs.bof thenResponse.Write "<p align='center' class='contents'> 暂没信息!</p>"elsetotalPut=rs.recordcountif currentpage<1 thencurrentpage=1end ifif (currentpage-1)*MaxPerPage>totalput thenif (totalPut mod MaxPerPage)=0 thencurrentpage= totalPut \ MaxPerPageelsecurrentpage= totalPut \ MaxPerPage + 1end ifend ifif currentPage=1 thenshowContentshowpage totalput,MaxPerPage,"newsml.asp" elseif (currentPage-1)*MaxPerPage<totalPut then rs.move (currentPage-1)*MaxPerPagedim bookmarkbookmark=rs.bookmarkshowContentshowpage totalput,MaxPerPage,"newsml.asp" elsecurrentPage=1showContentshowpage totalput,MaxPerPage,"newsml.asp" end ifend ifend ifsub showContentdim i,ji=0%><% do while not rs.eof %>2.循环结束代码<% i=i+1j=j+1if i>=MaxPerPage then Exit Doif i mod 2= 0 then response.write("</tr><tr>") rs.movenextlooprs.closeset rs=nothing%>3.翻页执行代码<%End SubFunction showpage(totalnumber,maxperpage,filename)Dim nIf totalnumber Mod maxperpage=0 Thenn= totalnumber \ maxperpageElsen= totalnumber \ maxperpage+1End IfResponse.Write "<form method=Post action="&filename&">"Response.Write "<p align='center' class='contents'> "If CurrentPage<2 ThenResponse.Write "<font class='contents'>首页上一页</font> "ElseResponse.Write "<a href="&filename&"?page=1 class='contents'>首页</a> "Response.Write "<a href="&filename&"?page="&CurrentPage-1&" class='contents'>上一页</a> "End IfIf n-currentpage<1 ThenResponse.Write "<font class='contents'>下一页尾页</font>"ElseResponse.Write "<a href="&filename&"?page="&(CurrentPage+1)&" class='contents'>" Response.Write "下一页</a> <a href="&filename&"?page="&n&" class='contents'>尾页</a>" End IfResponse.Write "<font class='contents'> 页次:</font><font class='contents'>"&CurrentPage&"</font><font class='contents'>/"&n&"页</font> " Response.Write "<font class='contents'> 共有"&totalnumber&"个信息"Response.Write "<font class='contents'>转到:</font><input type='text' name='page' size=2 maxlength=10 class=smallInput value="¤tpage&">"Response.Write " <input type='submit' class='button' value='GO' name='cndok'></form>" End Function%>****************************************************************************** 三.显示新闻的初始代码<!--#include file="conn.asp" --><%dim idid=request.QueryString("id")set rs=server.CreateObject("adodb.recordset")sql="select * from news where id="&id&"" rs.open sql,conn,1,1%>2.释放代码<%rs.closeset rs=nothingconn.closeset conn=Nothing%>。
Dreamweaver中时间、天气预报、滚动新闻条的制作
Dreamweaver中时间、天气预报、滚动新闻条的制作时间的制作<SCRIPT language=javaScript src="Include/time.js" type=text/javascript></SCRIPT> // JavaScript Document<!--var lunarInfo=new Array(/* 1900 */0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x 055d2,0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x 14977,0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x 04970,0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950,0x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4,0x025d0,0x092d0,0x0d2b2,0x0a950,0x 0b557,0x06ca0,0x0b550,0x15355,0x04da0,0x0a5d0,0x14573,0x052d0,0x0a9a8,0x0e950,0x 06aa0,0x0aea6,0x0ab50,0x04b60,0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x 056a0,0x096d0,0x04dd5,0x04ad0,0x0a4d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b5a0,0x 195a6,0x095b0,0x049b0,0x0a974,0x0a4b0,0x0b27a,0x06a50,0x06d40,0x0af46,0x0ab60,0x 09570,0x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0x0ab60,0x096d5,0x 092e0,0x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0x0abb7,0x025d0,0x092d0,0x0cab5,0x0a950,0x0b4a0,0x0baa4,0x0ad50,0x055d9,0x04ba0,0x0a5b0,0x15176,0x052b0,0x 0a930,0x07954,0x06aa0,0x0ad50,0x05b52,0x04b60,0x0a6e6,0x0a4e0,0x0d260,0x0ea65,0x0d530,0x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,0x0a4d0,0x1d0b6,0x0d250,0x0d520,0x 0dd45,0x0b5a0,0x056d0,0x055b2,0x049b0,0x0a577,0x0a4b0,0x0aa50,0x1b255,0x06d20,0x 0ada0,/* 2049 *///下面的是从 2050 到 2100 年的0x14b63, /* 2050 */0x09370, 0x049f8, 0x04970, 0x064b0, 0x168a6, /* 2055 */0x0ea50, 0x06b20, 0x1a6c4, 0x0aae0, 0x0a2e0, /* 2060 */0x0d2e3, 0x0c960, 0x0d557, 0x0d4a0, 0x0da50, /* 2065 */0x05d55, 0x056a0, 0x0a6d0, 0x055d4, 0x052d0, /* 2070 */0x0a9b8, 0x0a950, 0x0a4a0, 0x0b6a6, 0x0ad50, /* 2075 */0x055a0, 0x0aba0, 0x0a5b0, 0x052b0, 0x0b273, /* 2080 */0x06930, 0x07337, 0x06aa0, 0x0ad50, 0x14b55, /* 2085 */0x04b60, 0x0a570, 0x054e4, 0x0d260, 0x0e968, /* 2090 */0x0d520, 0x0daa0, 0x16aa6, 0x056d0, 0x04ae0, /* 2095 */0x0a9d4, 0x0a4d0, 0x0d150, 0x0f252, 0x0d520 /* 2100 */);var Animals=new Array("鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"); var Gan=new Array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸");var Zhi=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");var now = new Date();var SY = now.getYear();var SM = now.getMonth();var SD = now.getDate();//==== 传入 offset 传回干支, 0=甲子function cyclical(num){return(Gan[num%10]+Zhi[num%12]);}//==== 传回农历 y年的总天数function lYearDays(y){var i, sum = 348;for(i=0x8000; i>0x8; i>>=1) sum += (lunarInfo[y-1900] & i) ? 1 : 0;return(sum+leapDays(y));}//==== 传回农历 y年闰月的天数function leapDays(y){if(leapMonth(y)) return((lunarInfo[y-1900] & 0x10000) ? 30 : 29);else return(0);}//==== 传回农历 y年闰哪个月 1-12 , 没闰传回 0function leapMonth(y){return(lunarInfo[y-1900] & 0xf);}//====================================== 传回农历 y年m月的总天数function monthDays(y, m){return (lunarInfo[y-1900] & (0x10000>>m))? 30 : 29;}//==== 算出农历, 传入日期物件, 传回农历日期物件//==== 该物件属性有 .year .month .day .isLeap .yearCyl .dayCyl .monCylfunction Lunar(objDate){var i, leap=0, temp=0;var baseDate = new Date(1900,0,31);var offset = (objDate - baseDate)/86400000;this.dayCyl = offset + 40;this.monCyl = 14;for (i = 1900; i<2050 && offset>0; i++){temp = lYearDays(i);offset -= temp;this.monCyl += 12;}if (offset < 0){offset += temp;i--;this.monCyl -= 12;}this.year = i;this.yearCyl = i-1864;leap = leapMonth(i); //闰哪个月this.isLeap = false;for (i = 1; i < 13 && offset > 0; i++){//闰月if (leap > 0 && i == (leap+1) && this.isLeap == false)--i;this.isLeap = true;temp = leapDays(this.year);}else{temp = monthDays(this.year, i);}//解除闰月if (this.isLeap == true && i == (leap+1)) {this.isLeap = false;}offset -= temp;if (this.isLeap == false){this.monCyl++;}}if (offset == 0 && leap > 0 && i == leap + 1) {if (this.isLeap){this.isLeap = false;}elsethis.isLeap = true;--i;--this.monCyl;}}if (offset < 0){offset += temp;--i;--this.monCyl;}this.month = i;this.day = offset + 1;}function YYMMDD(){var cl = '<font color="#000000">';if (now.getDay() == 0) cl = '<font color="#000000">';if (now.getDay() == 6) cl = '<font color="#000000">';return(cl+SY+'年'+(SM+1)+'月'+'</font>');}function weekday(){var day = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");var cl = '<font color="#000000">';if (now.getDay() == 0) cl = '<font color="#000000">';if (now.getDay() == 6) cl = '<font color="#000000">';return(cl+ day[now.getDay()]+ '</font>');}//==== 中文日期function cDay(m, d){var nStr1 = new Array('日','一','二','三','四','五','六','七','八','九','十'); var nStr2 = new Array('初','十','廿','卅','');var s;if (m > 10){s = '十' + nStr1[m-10];}else{s = nStr1[m];}s += '月';switch (d){case 10:s += '初十'; break;case 20:s += '二十'; break;case 30:s += '三十'; break;default:s += nStr2[Math.floor(d/10)]; s += nStr1[d%10];}return(s);}function solarDay1(){var sDObj = new Date(SY, SM, SD);var lDObj = new Lunar(sDObj);var cl = '<font color="#000000" >';var tt = '【' + Animals[(SY-4)%12] + '】' + cyclical(lDObj.monCyl) + '月 ' + cyclical(lDObj.dayCyl++) + '日';return(cl+tt+'</font>');}function solarDay2(){var sDObj = new Date(SY, SM, SD);var lDObj = new Lunar(sDObj);var cl = '<font color="#000000" >';//农历BB'+(cld[d].isLeap?'闰 ':' ')+cld[d].lMonth+' 月 '+cld[d].lDay+' 日var tt = cyclical(SY-1900+36)+'年 '+cDay(lDObj.month,lDObj.day);return(cl+tt+'</font>');}function solarDay3(){var sTermInfo = newArray(0,21208,42467,63836,85337,107014,128867,150921,173149,195551,218072,2 40693,263343,285989,308563,331033,353350,375494,397447,419210,440795,4622 24,483532,504758);var solarTerm = new Array("小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至");var lFtv = new Array("0101*春节","0115 元宵节","0505 端午节","0707 七夕情人节","0715 中元节","0815 中秋节","0827 MM的生日","0909 重阳节","1208 腊八节","1224 小年","0100*除夕");var sFtv = new Array("0101*元旦","0214 情人节","0308 妇女节","0312 植树节","0315 消费者权益日","0401 愚人节","0407 偶今天又长一岁拉","0501 劳动节","0504 青年节","0512 护士节","0601 儿童节","0701 建党节香港回归纪念","0801 建军节","0808 父亲节","0909 毛席逝世纪念","0910 教师节","0928 孔子诞辰","1001*国庆节","1006 老人节","1024 联合国日","1112 孙中山诞辰","1220 澳门回归纪念","1225 圣诞节","1226 毛席诞辰");var sDObj = new Date(SY, SM, SD);var lDObj = new Lunar(sDObj);var lDPOS = new Array(3);var festival='',solarTerms='',solarFestival='',lunarFestival='',tmp1,tmp2;//农历节日for (i in lFtv)if (lFtv[i].match(/^(\d{2})(.{2})([\s\*])(.+)$/)) {tmp1=Number(RegExp.$1)-lDObj.month;tmp2=Number(RegExp.$2)-lDObj.day;if(tmp1==0 && tmp2==0) lunarFestival=RegExp.$4;}//国历节日for (i in sFtv)if (sFtv[i].match(/^(\d{2})(\d{2})([\s\*])(.+)$/)){tmp1 = Number(RegExp.$1)-(SM+1);tmp2 = Number(RegExp.$2)-SD;if (tmp1==0 && tmp2==0) solarFestival = RegExp.$4;}//节气tmp1 = new Date((31556925974.7*(SY-1900)+sTermInfo[SM*2+1]*60000)+Date.UTC(1900,0,6,2,5));tmp2 = tmp1.getUTCDate();if (tmp2 == SD) solarTerms = solarTerm[SM*2+1];tmp1 = new Date((31556925974.7*(SY-1900)+sTermInfo[SM*2]*60000)+Date.UTC(1900,0,6,2,5));tmp2 = tmp1.getUTCDate();if (tmp2 == SD) solarTerms = solarTerm[SM*2];return('<font color="green" STYLE="font-size:9pt;">'+festival+'</font>'); }//显示当前时间function CurentTime(){var now = new Date();var hh = now.getHours();var mm = now.getMinutes();var ss = now.getTime() % 60000;ss = (ss - (ss % 1000)) / 1000;var clock = hh+':';if (mm < 10) clock += '0';clock += mm+':';if (ss < 10) clock += '0';clock += ss;return(clock);}function refreshCalendarClock() //{document.all.ClockTime.innerHTML = CurentTime();}//显示当前时间function setCalendar(){document.write("<table border='0' cellspacing='0' style='color:#000000;font-size:12px;' cellpadding='0'");document.write("<tr><td width='10'></td><td>"+YYMMDD()+SD+"日"+" ");document.write(weekday()+"<span style='display:none;'>"+"<fontid=ClockTime >"+CurentTime()+"</font>"+"</span>"+" ");document.write("<spanstyle='display:none;'>"+solarDay1()+"</span>"+solarDay2()+" "+"<span style='display:none;'>"+solarDay3()+"</span>"+"</td></tr></table>");}setCalendar();setInterval('refreshCalendarClock()', 1000);//1秒钟刷新1次当前时间(不刷新日期) //-->天气预报的制作在网页中嵌入下列代码,修改id即可<IFRAME marginWidth=0 marginHeight=0src="/m/p2/weather1.htm?id=101080701T" frameBorder=0 width=200 scrolling=no height=24 allowTransparency></IFRAME>滚动新闻条的制作<iframe name=sina_roll src=/o/allnews/input/index.html height=11 width=100% frameborder=No border=0 marginwidth=0 marginheight=0 scrolling=No></iframe>。
天气预报接口代码
天气预报接口代码(1)这是你想要的天气预报代码,由中央气象台提供数据,最准确最权威的天气预报,能够根据访客不同的IP地址显示不同城市的天气预报下面是源程序代码:<iframe src="" width="160" height="60"frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe> (3)名称:新浪天气预报代码代码:<IFRAME ID='ifm2' WIDTH='260' HEIGHT='70' ALIGN='CENTER' MARGINWIDTH='0' MARGINHEIGHT='0' HSPACE='0' VSPACE='0' FRAMEBORDER='0' SCROLLING='NO'src=""></iframe>说明:这种适合于在网页的头栏插入。
上面的城市可以自定,比如石家庄可改成别的。
城市代码:"110100","北京""120100","天津"1"130101","石家庄" "130201","唐山" "130301","秦皇岛" "130701","张家口" "130801","承德" "131001","廊坊" "130401","邯郸" "130501","邢台" "130601","保定" "130901","沧州" "133001","衡水" "140101","太原" "140201","大同" "140301","阳泉"2"140501","晋城" "140601","朔州" "142201","忻州" "142331","离石" "142401","榆次" "142601","临汾" "142701","运城" "140401","长治" "150101","呼和浩特" "150201","包头" "150301","乌海" "152601","集宁" "152701","巴彦浩特" "152801","临河"3"152921","鄂尔多斯" "150401","赤峰" "152301","通辽" "152502","锡林浩特" "152101","海拉尔" "152201","乌兰浩特" "210101","沈阳" "210201","大连" "210301","鞍山" "210401","抚顺" "210501","本溪" "210701","锦州" "210801","营口" "210901","阜新"4"211101","盘锦" "211201","铁岭" "211301","朝阳" "211401","葫芦岛" "210601","丹东" "220101","长春" "220201","吉林" "220301","四平" "220401","辽源" "220601","松原" "222301","白城" "222401","延边" "220501","通化" "230101","哈尔滨"5"230301","鸡西" "230401","鹤岗" "230501","双鸭山" "230701","伊春" "230801","佳木斯" "230901","七台河" "231001","牡丹江" "232301","绥化" "230201","齐齐哈尔" "230601","大庆" "232601","黑河" "232700","大兴安岭" "310100","上海" "320101","南京"6"320201","无锡" "320301","徐州" "320401","常州" "320501","苏州" "320600","南通" "320701","连云港" "320801","淮阴" "320901","盐城" "321001","扬州" "321101","镇江" "321102","泰州" "321103","宿迁" "330101","杭州" "330201","宁波"7"330301","温州" "330401","嘉兴" "330501","湖州" "330601","绍兴" "330701","金华" "330801","衢州" "330901","舟山" "332501","丽水" "332602","台州" "340101","合肥" "340201","芜湖" "340301","蚌埠" "340401","淮南" "340501","马鞍山"8"340601","淮北" "340701","铜陵" "340801","安庆" "341001","黄山市" "342101","阜阳" "342201","宿州" "342301","滁州" "342401","六安" "342501","宣城" "342601","巢湖" "342901","池州" "350101","福州" "350201","厦门" "350301","莆田"9"350401","三明" "350501","泉州" "350601","漳州" "352101","南平" "352201","宁德" "352601","龙岩" "352602","陇南" "352603","庆阳" "360101","南昌" "360201","景德镇" "362101","赣州" "360301","萍乡" "360401","九江" "360501","新余"10"360601","鹰潭" "362201","宜春" "362301","上饶" "362401","吉安" "370101","济南" "370201","青岛" "370301","淄博" "370401","枣庄" "370501","东营" "370601","烟台" "370701","潍坊" "370801","济宁" "370901","泰安" "371001","威海"11"371100","日照" "372301","滨州" "372401","德州" "372501","聊城" "372801","临沂" "372901","菏泽" "372902","莱芜" "410101","郑州" "410201","开封" "410301","洛阳" "410401","平顶山" "410501","安阳" "410601","鹤壁" "410701","新乡"12"410801","焦作" "410901","濮阳" "411001","许昌" "411101","漯河" "411201","三门峡" "412301","商丘" "412701","周口" "412801","驻马店" "412901","南阳" "413001","信阳" "420101","武汉" "420201","黄石" "420301","十堰" "420400","随州"13"420501","宜昌" "420601","襄樊" "420701","鄂州" "420801","荆门" "422103","黄冈" "422201","孝感" "422301","咸宁" "422421","荆州" "422801","恩施" "430101","长沙" "430401","衡阳" "430501","邵阳" "432801","郴州" "432901","永州"14"430801","韶山" "430802","张家界" "433001","怀化" "433101","吉首" "430201","株洲" "430301","湘潭" "430601","岳阳" "430701","常德" "432301","益阳" "432501","娄底" "440101","广州" "440301","深圳" "441501","汕尾" "441301","惠州"15"441601","河源" "441801","清远" "441901","东莞" "440401","珠海" "440701","江门" "441201","肇庆" "442001","中山" "440801","湛江" "440901","茂名" "440201","韶关" "440501","汕头" "441401","梅州" "441701","阳江" "441702","潮州"16"441703","顺德" "441704","揭阳" "441705","云浮" "450101","南宁" "450401","梧州" "452501","玉林" "450301","桂林" "452601","百色" "452701","河池" "452802","钦州" "450201","柳州" "450501","北海" "450502","防城港" "450503","贵港"17"450504","贺州" "460100","海口" "460200","三亚" "460300","西沙群岛" "510101","成都" "513321","眉山" "513101","雅安" "513229","峨嵋山" "510301","自贡" "500100","重庆" "500102","万州" "500103","涪陵" "512901","南充" "510501","泸州"18"510601","德阳" "510701","绵阳" "510901","遂宁" "511001","内江" "511101","乐山" "512501","宜宾" "510801","广元" "513021","达州" "513401","资阳" "510401","攀枝花" "510402","阿坝" "510403","甘孜" "510404","凉山" "510405","广安"19"510406","巴中" "500239","黔江" "520101","贵阳" "520200","六盘水" "522201","铜仁" "522501","安顺" "522601","凯里" "522701","都匀" "522301","兴义" "522421","毕节" "522101","遵义" "530101","昆明" "530201","德宏" "532201","曲靖"20"532301","楚雄" "532401","玉溪" "532501","红河" "532621","文山" "532721","思茅" "532101","昭通" "532821","西双版纳" "532901","大理" "533001","保山" "533121","怒江" "533221","丽江" "533321","迪庆" "533521","临沧" "540101","拉萨"21"542121","昌都" "542221","山南" "542301","日喀则" "542421","那曲" "542523","阿里" "542621","林芝" "610101","西安" "610201","铜川" "610301","宝鸡" "610401","咸阳" "612101","渭南" "612301","汉中" "612401","安康" "612501","商洛"22"612601","延安" "612701","榆林" "620101","兰州" "620401","白银" "620301","金昌" "620501","天水" "622201","张掖" "622301","武威" "622421","定西" "622701","平凉" "622901","临夏" "620201","嘉峪关" "622102","酒泉" "630100","西宁"23"632121","果洛" "632221","海西" "632321","格尔木" "632521","海东" "632621","海北" "632721","玉树" "632802","黄南" "640101","银川" "640201","石嘴山" "642101","吴忠" "642221","固原" "650101","乌鲁木齐" "650201","克拉玛依" "652101","吐鲁番"24"652201","哈密" "652301","昌吉" "652701","博乐" "652801","库尔勒" "652901","阿克苏" "653001","克州" "653101","喀什" "654101","伊犁" "655001","石河子" "655002","塔城" "655003","阿勒泰" "710001","台北" "211001","辽阳" "653201","和田"25"820000","澳门""810000","香港"第一种:代码:效果预览:<iframe width="145" height="130" border="0" align="center" marginwidth="0"marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"src="" allowTransparency="true"></iframe>说明:这种适合于在网页的边栏插入。
城市天气三小时预报 天气预报api接口大全实现
{
"weatherid": "02",
"weather": "阴",
"temp1": "23",
"temp2": "22",
"sh": "02",
"eh": "05",
"date": "20140531",
"sfdate": "20140531020000",
"efdate": "20140531050000"
},
{
"weatherid": "01",
"weather": "多云",
"temp1": "26",
"temp2": "23",
"sh": "08",
"eh": "02",
"date": "20140602",
"sfdate": "20140602200000",
"efdate": "20140603020000"
},
{
"weatherid": "07",
"weather": "小雨",
"temp1": "23",
天气预报代码
qq.htm代码如下:引用:<html xmlns="/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>迷你天气预报</title><style>body{margin:0;padding:0;background:#fff;font-size:12px;}form{margin:0;padding:0;}img{border:0;}*{overflow:hidden;line-height:150%:}a{color:#666666;text-decoration:none;}a:visited{color:#666666}a:hover{color:#666666;text-decoration:underline;}#Head_Area {BACKGROUND: url() 10% top; MARGIN-BOTTOM: 0px; OVERFLOW: hidden; WIDTH: 230px;HEIGHT: 15px}#Head_Area #Wealth {FLOAT: left; WIDTH: 230px; LINE-HEIGHT: 15px; PADDING-TOP: 0px;}#Head_Area #Wealth A {COLOR: #666666}</style><!--[if ie 7]><style>.cl{height:0;}</style><![endif]--><script type="text/javascript" src="../js/j.minisite.weather.js"></script></head><body onLoad="document.execCommand('BackgroundImageCache',false,true);"> <div id="Head_Area"><div id="Wealth"></div><script type="text/javascript">/*<![CDATA[*/MiniSite.Weather.print("Wealth");/*]]>*/</script></div></body></html>j.minisite.weather.js如下:引用:/** created by WangSo at 2008-4-9*/var MiniSite = new Object();MiniSite.Browser = {ie: /msie/.test(erAgent.toLowerCase()),moz: /gecko/.test(erAgent.toLowerCase()),opera: /opera/.test(erAgent.toLowerCase())};MiniSite.$ = function(s){return (typeof s == 'object') ? s: document.getElementById(s);};MiniSite.JsLoader = {load: function(sUrl, fCallback){var _script = document.createElement('script');_script.setAttribute('type', 'text/javascript');_script.setAttribute('src', sUrl);document.getElementsByTagName('head')[0].appendChild(_script);if (MiniSite.Browser.ie){_script.onreadystatechange = function(){if (this.readyState=='loaded' || this.readyState=='complete'){fCallback();}};}else if (MiniSite.Browser.moz){_script.onload = function(){fCallback();};}else{fCallback();}}};MiniSite.Cookie = {set: function(name, value, expires, path, domain){if (typeof expires == "undefined"){expires = new Date(new Date().getTime() + 365*24*3600*100);}document.cookie = name + "=" + escape(value) +((expires) ? "; expires=" + expires.toGMTString() : "") +((path) ? "; path=" + path : "; path=/") +((domain) ? "; domain=" + domain : "");},get: function(name){var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));if (arr != null){return unescape(arr[2]);}return null;},clear: function(name, path, domain){if (this.get(name)){document.cookie = name + "=" +((path) ? "; path=" + path : "; path=/") +((domain) ? "; domain=" + domain : "") +";expires=Fri, 02-Jan-1970 00:00:00 GMT";}}};MiniSite.Weather = {defaultCity: 125,city: {"北京市": {"_": 125,"北京市": 125},"上海市": {"_": 252,"上海市": 252},"天津市": {"_": 127,"天津市": 127,"塘沽区": 132},"重庆市" : {"_": 212,"奉节区": 201,"重庆市": 212,"涪陵区": 213},"香港": {"_": 1,"香港": 1},"澳门": {"_": 2,"澳门": 2},"台湾省": {"_": 280,"台北市": 280},"云南省": {"_": 179,"昭通市": 173,"丽江市": 174,"曲靖市": 175,"保山市": 176,"大理州": 177,"楚雄州": 178,"昆明市": 179,"瑞丽市": 180,"玉溪市": 181,"临沧市": 182,"思茅市": 184,"红河州": 185,"文山州": 369,"西双版纳州": 370,"怒江州": 372,"迪庆州": 373},"内蒙古": {"_": 69,"呼伦贝尔市": 4,"兴安盟": 7,"锡林郭勒盟": 16,"巴彦淖尔市": 63,"包头市": 64,"呼和浩特市": 69,"锡林浩特市": 99,"通辽市": 101,"赤峰市": 106,"乌海市": 382,"鄂尔多斯市": 383,"乌兰察布市": 384 },"吉林省": {"_": 103,"辽源市": 34,"通化市": 36,"白城市": 37,"松原市": 96,"长春市": 103,"吉林市": 104,"桦甸市": 109,"延边州": 110,"集安市": 118,"白山市": 119,"四平市": 385},"四川省": {"_": 166,"甘孜州": 162,"阿坝州": 163,"成都市": 166,"雅安市": 168,"峨眉山市": 170,"乐山市": 171,"宜宾市": 172,"巴中市": 199,"达州市": 200,"遂宁市": 204,"南充市": 205,"泸州市": 216,"自贡市": 359,"攀枝花市": 360,"德阳市": 361,"广元市": 362,"内江市": 363,"广安市": 364,"眉山市": 365,"资阳市": 366,"凉山州": 367 },"宁夏": {"_": 78,"石嘴山市": 54,"银川市": 78,"吴忠市": 83,"固原市": 209 },"安徽省": {"_": 248,"淮南市": 75,"马鞍山市": 76,"淮北市": 77,"铜陵市": 92,"滁州市": 95,"巢湖市": 100,"池州市": 102,"宣城市": 105,"亳州市": 238,"阜阳市": 241,"六安市": 242,"蚌埠市": 243,"合肥市": 248,"芜湖市": 249,"安庆市": 253,"黄山市": 254 },"山东省": {"_": 140,"德州市": 134,"滨州市": 135,"烟台市": 136,"聊城市": 139,"济南市": 140,"泰安市": 141,"淄博市": 142,"潍坊市": 143,"青岛市": 144,"济宁市": 146,"日照市": 147,"泰山市": 156,"枣庄市": 159,"东营市": 160,"威海市": 164,"莱芜市": 165,"临沂市": 183,"菏泽市": 206 },"山西省": {"_": 84,"长治市": 9,"晋中市": 22,"朔州市": 70,"大同市": 72,"吕梁市": 80,"忻州市": 81,"阳泉市": 85,"临汾市": 88,"运城市": 93,"晋城市": 94,"五台山市": 381 },"广东省": {"_": 292,"南雄市": 235,"韶关市": 283,"清远市": 284,"梅州市": 285,"肇庆市": 291,"广州市": 292,"河源市": 293,"****市": 294,"深圳市": 296,"汕尾市": 297,"湛江市": 300,"阳江市": 301,"茂名市": 302,"佛冈市": 322,"梅县市": 323,"电白市": 324,"高要市": 325,"珠海市": 330,"佛山市": 331,"江门市": 332,"东莞市": 334,"中山市": 335,"潮州市": 336,"揭阳市": 337,"云浮市": 338 },"广西": {"_": 295,"桂林市": 232,"柳州市": 282,"百色市": 288,"贵港市": 289,"梧州市": 290,"南宁市": 295,"钦州市": 298,"北海市": 299,"防城港市": 339,"玉林市": 340,"贺州市": 341,"来宾市": 342,"崇左市": 343},"新疆": {"_": 28,"昌吉州": 19,"克孜勒苏柯尔克孜自治州": 20,"伊犁州": 21,"阿拉尔市": 23,"克拉玛依市": 24,"博尔塔拉州": 27,"乌鲁木齐市": 28,"吐鲁番市": 31,"阿克苏市": 32,"石河子市": 33,"喀什市": 35,"和田市": 39,"哈密市": 41,"奇台市": 52},"江苏省": {"_": 244,"无锡市": 43,"苏州市": 44,"盱眙市": 45,"赣榆市": 46,"东台市": 47,"镇江市": 59,"泰州市": 61,"宿迁市": 62,"徐州市": 236,"连云港市": 237,"淮安市": 240,"南京市": 244,"扬州市": 245,"盐城市": 246,"南通市": 247,"常州市": 250 },"江西省": {"_": 264,"庐山市": 111,"玉山市": 137,"贵溪市": 138,"广昌市": 145,"萍乡市": 153,"新余市": 154,"宜春市": 224,"赣州市": 234,"九江市": 258,"景德镇市": 259,"南昌市": 264,"鹰潭市": 265,"上饶市": 267,"抚州市": 273 },"河北省": {"_": 82,"邯郸市": 3,"衡水市": 8,"石家庄市": 82,"邢台市": 86,"张家口市": 120,"承德市": 121,"廊坊市": 126,"唐山市": 128,"保定市": 130,"沧州市": 131 },"河南省": {"_": 189,"安阳市": 89,"三门峡市": 188,"郑州市": 189,"南阳市": 192,"周口市": 193,"驻马店市": 197,"信阳市": 198,"开封市": 207,"洛阳市": 228,"平顶山市": 231,"焦作市": 251,"鹤壁市": 260,"新乡市": 304,"濮阳市": 305,"许昌市": 306,"漯河市": 307,"商丘市": 308,"济源市": 309 },"浙江省": {"_": 255,"湖州市": 65,"嵊州市": 66,"平湖市": 67,"石浦市": 68,"宁海市": 71,"洞头市": 73,"舟山市": 74,"杭州市": 255,"嘉兴市": 256,"金华市": 261,"绍兴市": 262,"宁波市": 263,"衢州市": 266,"丽水市": 268,"台州市": 269,"温州市": 272},"海南省": {"_": 303,"海口市": 303,"三亚市": 344,"屯昌市": 345,"琼海市": 346,"儋州市": 347,"文昌市": 348,"万宁市": 349,"东方市": 350,"澄迈市": 351,"定安市": 352,"临高市": 353,"白沙黎族自治县": 354,"乐东黎族自治县": 355,"陵水黎族自治县": 356,"保亭黎族苗族自治县": 357,"琼中黎族苗族自治县": 358 },"湖北省": {"_": 211,"襄樊市": 196,"荆门市": 202,"黄冈市": 203,"恩施州": 208,"武汉市": 211,"黄石市": 310,"鄂州市": 314,"孝感市": 315,"随州市": 317,"仙桃市": 318,"天门市": 319,"潜江市": 320,"神农架市": 321 },"湖南省": {"_": 218,"张家界市": 214,"岳阳市": 215,"怀化市": 217,"长沙市": 218,"邵阳市": 222,"益阳市": 223,"郴州市": 233,"桑植市": 311,"沅陵市": 312,"南岳市": 313,"株洲市": 326,"湘潭市": 327,"衡阳市": 328,"娄底市": 329,"常德市": 387 },"甘肃省": {"_": 57,"张掖市": 49,"金昌市": 50,"武威市": 51,"兰州市": 57,"白银市": 58,"定西市": 60,"平凉市": 90,"庆阳市": 91,"甘南市": 225,"临夏市": 229,"天水市": 377,"酒泉市": 379,"陇南市": 380},"福建省": {"_": 276,"莆田市": 107,"浦城市": 271,"南平市": 274,"宁德市": 275,"福州市": 276,"龙岩市": 277,"三明市": 278,"泉州市": 279,"漳州市": 286,"厦门市": 287},"**": {"_": 150,"那曲地区": 148,"日喀则地区": 149,"**市": 150,"山南地区": 151,"阿里地区": 152,"昌都地区": 161,"林芝地区": 169 },"贵州省": {"_": 227,"毕节市": 219,"遵义市": 220,"铜仁市": 221,"安顺市": 226,"贵阳市": 227,"黔西南州": 230,"六盘水市": 368 },"辽宁省": {"_": 115,"葫芦岛市": 25,"盘锦市": 26,"辽阳市": 29,"铁岭市": 30,"阜新市": 108,"朝阳市": 112,"锦州市": 113,"鞍山市": 114,"沈阳市": 115,"本溪市": 116,"抚顺市": 117,"营口市": 123,"丹东市": 124,"瓦房店市": 129,"大连市": 133 },"陕西省": {"_": 186,"榆林市": 79,"延安市": 87,"西安市": 186,"渭南市": 187,"汉中市": 190,"商洛市": 191,"安康市": 194,"铜川市": 374,"宝鸡市": 375,"咸阳市": 376 },"青海": {"_": 56,"海北州": 48,"海南州": 55,"西宁市": 56,"玉树州": 155,"黄南州": 157,"果洛州": 158,"海西州": 195,"海东市": 210},"黑龙江省": {"_": 17,"大兴安岭地区": 5,"黑河市": 6,"齐齐哈尔市": 10,"绥化市": 11,"鹤岗市": 12,"佳木斯市": 13,"伊春市": 14,"双鸭山市": 15,"哈尔滨市": 17,"鸡西市": 18,"漠河市": 38,"大庆市": 40,"七台河市": 42,"牡丹江市": 97,"绥芬河市": 98}},_print: function(province, city, conainter){if (typeof this.city[province] != "undefined"){if (typeof this.city[province][city] != "undefined"){var _city_ = this.city[province][city];}else if (typeof this.city[province]["_"] != "undefined"){var _city_ = this.city[province]["_"];}else{var _city_ = this.defaultCity;}}else{var _city_ = this.defaultCity;}MiniSite.JsLoader.load("/inc/minisite_"+_city_+".js", function(){try{MiniSite.$(conainter).innerHTML = "<a href='#'onclick=\"window.open('/inc/07_dc"+ _city_ + ".htm','','width=630,height=380,resizable=0')\"target='_blank'>"+ __minisite__weather__ + "</a>";}catch (e){}});},print: function(conainter){var ok = function(){var province = null;var city = null;var ipAddress = MiniSite.Cookie.get("QQ_IPAddress");if (ipAddress != null){try{var ipAddressArr = ipAddress.split(",");province = ipAddressArr[0];city =ipAddressArr[1];}catch (e){}}MiniSite.Weather._print(province, city, conainter);};if (!MiniSite.Cookie.get("QQ_IPAddress")){MiniSite.JsLoader.load(":80/ipaddress", function(){if (typeof IPData != "undefined"){MiniSite.Cookie.set('QQ_IPAddress', IPData[2]+','+IPData[3]);ok();}});}else{ok();}}};。
国家气象局免费天气预报接口,城市代码(JSON格式)
{"城市代码": [{"省": "北京","市": [{"市名": "北京","编码": "101010100"},{"市名": "朝阳","编码": "101010300"},{"市名": "顺义","编码": "101010400"},{"市名": "怀柔","编码": "101010500"},{"市名": "通州","编码": "101010600"},{"市名": "昌平","编码": "101010700"},{"市名": "延庆","编码": "101010800"},{"市名": "丰台","编码": "101010900"},{"市名": "石景山","编码": "101011000"},{"市名": "大兴","编码": "101011100"{"市名": "房山","编码": "101011200" },{"市名": "密云","编码": "101011300" },{"市名": "门头沟","编码": "101011400" },{"市名": "平谷","编码": "101011500" },{"市名": "八达岭","编码": "101011600" },{"市名": "佛爷顶","编码": "101011700" },{"市名": "汤河口","编码": "101011800" },{"市名": "密云上甸子","编码": "101011900" },{"市名": "斋堂","编码": "101012000" },{"市名": "霞云岭","编码": "101012100" },{"市名": "北京城区","编码": "101012200"{"市名": "海淀","编码": "101010200"}]},{"省": "天津市","市": [{"市名": "天津","编码": "101030100"},{"市名": "宝坻","编码": "101030300"},{"市名": "东丽","编码": "101030400"},{"市名": "西青","编码": "101030500"},{"市名": "北辰","编码": "101030600"},{"市名": "蓟县","编码": "101031400"},{"市名": "汉沽","编码": "101030800"},{"市名": "静海","编码": "101030900"},{"市名": "津南","编码": "101031000"},{"市名": "塘沽","编码": "101031100"},{"市名": "大港","编码": "101031200"},{"市名": "武清","编码": "101030200"},{"市名": "宁河","编码": "101030700"}]},{"省": "上海","市": [{"市名": "上海","编码": "101020100"},{"市名": "宝山","编码": "101020300"},{"市名": "嘉定","编码": "101020500"},{"市名": "南汇","编码": "101020600"},{"市名": "浦东","编码": "101021300"},{"市名": "青浦","编码": "101020800"},{"市名": "松江","编码": "101020900"},{"市名": "奉贤","编码": "101021000"},{"市名": "崇明","编码": "101021100"},{"市名": "徐家汇","编码": "101021200"},{"市名": "闵行","编码": "101020200"},{"市名": "金山","编码": "101020700"}]},{"省": "河北","市": [{"市名": "石家庄","编码": "101090101"},{"市名": "张家口","编码": "101090301"},{"市名": "承德","编码": "101090402"},"市名": "唐山","编码": "101090501"},{"市名": "秦皇岛","编码": "101091101"},{"市名": "沧州","编码": "101090701"},{"市名": "衡水","编码": "101090801"},{"市名": "邢台","编码": "101090901"},{"市名": "邯郸","编码": "101091001"},{"市名": "保定","编码": "101090201"},{"市名": "廊坊","编码": "101090601"}]},{"省": "河南","市": [{"市名": "郑州","编码": "101180101"},{"市名": "新乡","编码": "101180301"{"市名": "许昌","编码": "101180401" },{"市名": "平顶山","编码": "101180501" },{"市名": "信阳","编码": "101180601" },{"市名": "南阳","编码": "101180701" },{"市名": "开封","编码": "101180801" },{"市名": "洛阳","编码": "101180901" },{"市名": "商丘","编码": "101181001" },{"市名": "焦作","编码": "101181101" },{"市名": "鹤壁","编码": "101181201" },{"市名": "濮阳","编码": "101181301" },{"市名": "周口","编码": "101181401"{"市名": "漯河","编码": "101181501"},{"市名": "驻马店","编码": "101181601"},{"市名": "三门峡","编码": "101181701"},{"市名": "济源","编码": "101181801"},{"市名": "安阳","编码": "101180201"}]},{"省": "安徽","市": [{"市名": "合肥","编码": "101220101"},{"市名": "芜湖","编码": "101220301"},{"市名": "淮南","编码": "101220401"},{"市名": "马鞍山","编码": "101220501"},{"市名": "安庆",},{"市名": "宿州","编码": "101220701" },{"市名": "阜阳","编码": "101220801" },{"市名": "亳州","编码": "101220901" },{"市名": "黄山","编码": "101221001" },{"市名": "滁州","编码": "101221101" },{"市名": "淮北","编码": "101221201" },{"市名": "铜陵","编码": "101221301" },{"市名": "宣城","编码": "101221401" },{"市名": "六安","编码": "101221501" },{"市名": "巢湖","编码": "101221601" },{"市名": "池州",},{"市名": "蚌埠","编码": "101220201"}]},{"省": "浙江","市": [{"市名": "杭州","编码": "101210101"},{"市名": "舟山","编码": "101211101"},{"市名": "湖州","编码": "101210201"},{"市名": "嘉兴","编码": "101210301"},{"市名": "金华","编码": "101210901"},{"市名": "绍兴","编码": "101210501"},{"市名": "台州","编码": "101210601"},{"市名": "温州","编码": "101210701"},{"市名": "丽水","编码": "101210801"},{"市名": "衢州","编码": "101211001"},{"市名": "宁波","编码": "101210401"}]},{"省": "重庆","市": [{"市名": "重庆","编码": "101040100"},{"市名": "合川","编码": "101040300"},{"市名": "南川","编码": "101040400"},{"市名": "江津","编码": "101040500"},{"市名": "万盛","编码": "101040600"},{"市名": "渝北","编码": "101040700"},{"市名": "北碚","编码": "101040800"},"市名": "巴南","编码": "101040900" },{"市名": "长寿","编码": "101041000" },{"市名": "黔江","编码": "101041100" },{"市名": "万州天城","编码": "101041200" },{"市名": "万州龙宝","编码": "101041300" },{"市名": "涪陵","编码": "101041400" },{"市名": "开县","编码": "101041500" },{"市名": "城口","编码": "101041600" },{"市名": "云阳","编码": "101041700" },{"市名": "巫溪","编码": "101041800" },{"市名": "奉节","编码": "101041900" },"市名": "巫山","编码": "101042000" },{"市名": "潼南","编码": "101042100" },{"市名": "垫江","编码": "101042200" },{"市名": "梁平","编码": "101042300" },{"市名": "忠县","编码": "101042400" },{"市名": "石柱","编码": "101042500" },{"市名": "大足","编码": "101042600" },{"市名": "荣昌","编码": "101042700" },{"市名": "铜梁","编码": "101042800" },{"市名": "璧山","编码": "101042900" },{"市名": "丰都","编码": "101043000" },"市名": "武隆","编码": "101043100"},{"市名": "彭水","编码": "101043200"},{"市名": "綦江","编码": "101043300"},{"市名": "酉阳","编码": "101043400"},{"市名": "秀山","编码": "101043600"},{"市名": "沙坪坝","编码": "101043700"},{"市名": "永川","编码": "101040200"}]},{"省": "福建","市": [{"市名": "福州","编码": "101230101"},{"市名": "泉州","编码": "101230501"},{"市名": "漳州","编码": "101230601"{"市名": "龙岩","编码": "101230701"},{"市名": "晋江","编码": "101230509"},{"市名": "南平","编码": "101230901"},{"市名": "厦门","编码": "101230201"},{"市名": "宁德","编码": "101230301"},{"市名": "莆田","编码": "101230401"},{"市名": "三明","编码": "101230801"}]},{"省": "甘肃","市": [{"市名": "兰州","编码": "101160101"},{"市名": "平凉","编码": "101160301"},{"市名": "庆阳",},{"市名": "武威","编码": "101160501" },{"市名": "金昌","编码": "101160601" },{"市名": "嘉峪关","编码": "101161401" },{"市名": "酒泉","编码": "101160801" },{"市名": "天水","编码": "101160901" },{"市名": "武都","编码": "101161001" },{"市名": "临夏","编码": "101161101" },{"市名": "合作","编码": "101161201" },{"市名": "白银","编码": "101161301" },{"市名": "定西","编码": "101160201" },{"市名": "张掖",}]},{"省": "广东","市": [{"市名": "广州","编码": "101280101"},{"市名": "惠州","编码": "101280301"},{"市名": "梅州","编码": "101280401"},{"市名": "汕头","编码": "101280501"},{"市名": "深圳","编码": "101280601"},{"市名": "珠海","编码": "101280701"},{"市名": "佛山","编码": "101280800"},{"市名": "肇庆","编码": "101280901"},{"市名": "湛江","编码": "101281001"},{"编码": "101281101" },{"市名": "河源","编码": "101281201" },{"市名": "清远","编码": "101281301" },{"市名": "云浮","编码": "101281401" },{"市名": "潮州","编码": "101281501" },{"市名": "东莞","编码": "101281601" },{"市名": "中山","编码": "101281701" },{"市名": "阳江","编码": "101281801" },{"市名": "揭阳","编码": "101281901" },{"市名": "茂名","编码": "101282001" },{"市名": "汕尾","编码": "101282101" },{"编码": "101280201"}]},{"省": "广西","市": [{"市名": "南宁","编码": "101300101"},{"市名": "柳州","编码": "101300301"},{"市名": "来宾","编码": "101300401"},{"市名": "桂林","编码": "101300501"},{"市名": "梧州","编码": "101300601"},{"市名": "防城港","编码": "101301401"},{"市名": "贵港","编码": "101300801"},{"市名": "玉林","编码": "101300901"},{"市名": "百色","编码": "101301001"},{"市名": "钦州","编码": "101301101"},{"市名": "河池","编码": "101301201"},{"市名": "北海","编码": "101301301"},{"市名": "崇左","编码": "101300201"},{"市名": "贺州","编码": "101300701"}]},{"省": "贵州","市": [{"市名": "贵阳","编码": "101260101"},{"市名": "安顺","编码": "101260301"},{"市名": "都匀","编码": "101260401"},{"市名": "兴义","编码": "101260906"},{"市名": "铜仁","编码": "101260601"},{"市名": "毕节","编码": "101260701"},{"市名": "六盘水","编码": "101260801"},{"市名": "遵义","编码": "101260201"},{"市名": "凯里","编码": "101260501"}]},{"省": "云南","市": [{"市名": "昆明","编码": "101290101"},{"市名": "红河","编码": "101290301"},{"市名": "文山","编码": "101290601"},{"市名": "玉溪","编码": "101290701"},{"市名": "楚雄","编码": "101290801"},{"市名": "普洱","编码": "101290901"},{"市名": "昭通","编码": "101291001"},{"市名": "临沧","编码": "101291101"},{"市名": "怒江","编码": "101291201"},{"市名": "香格里拉","编码": "101291301"},{"市名": "丽江","编码": "101291401"},{"市名": "德宏","编码": "101291501"},{"市名": "景洪","编码": "101291601"},{"市名": "大理","编码": "101290201"},{"市名": "曲靖","编码": "101290401"},{"市名": "保山","编码": "101290501"}]},{"省": "内蒙古","市": [{"市名": "呼和浩特","编码": "101080101"},{"市名": "乌海","编码": "101080301"},{"市名": "集宁","编码": "101080401"},{"市名": "通辽","编码": "101080501"},{"市名": "阿拉善左旗","编码": "101081201"},{"市名": "鄂尔多斯","编码": "101080701"},{"市名": "临河","编码": "101080801"},{"市名": "锡林浩特","编码": "101080901"},{"市名": "呼伦贝尔","编码": "101081000"},{"市名": "乌兰浩特","编码": "101081101"},{"市名": "包头","编码": "101080201"},{"市名": "赤峰","编码": "101080601"}]},{"省": "江西","市": [{"市名": "南昌","编码": "101240101"},{"市名": "上饶","编码": "101240301"},{"市名": "抚州","编码": "101240401"},{"市名": "宜春","编码": "101240501"},{"市名": "鹰潭","编码": "101241101"},{"市名": "赣州","编码": "101240701"},{"市名": "景德镇","编码": "101240801"},{"市名": "萍乡","编码": "101240901"},"市名": "新余","编码": "101241001"},{"市名": "九江","编码": "101240201"},{"市名": "吉安","编码": "101240601"}]},{"省": "湖北","市": [{"市名": "武汉","编码": "101200101"},{"市名": "黄冈","编码": "101200501"},{"市名": "荆州","编码": "101200801"},{"市名": "宜昌","编码": "101200901"},{"市名": "恩施","编码": "101201001"},{"市名": "十堰","编码": "101201101"},{"市名": "神农架","编码": "101201201"{"市名": "随州","编码": "101201301"},{"市名": "荆门","编码": "101201401"},{"市名": "天门","编码": "101201501"},{"市名": "仙桃","编码": "101201601"},{"市名": "潜江","编码": "101201701"},{"市名": "襄樊","编码": "101200201"},{"市名": "鄂州","编码": "101200301"},{"市名": "孝感","编码": "101200401"},{"市名": "黄石","编码": "101200601"},{"市名": "咸宁","编码": "101200701"}]},{"省": "四川","市": [{"市名": "成都","编码": "101270101"},{"市名": "自贡","编码": "101270301"},{"市名": "绵阳","编码": "101270401"},{"市名": "南充","编码": "101270501"},{"市名": "达州","编码": "101270601"},{"市名": "遂宁","编码": "101270701"},{"市名": "广安","编码": "101270801"},{"市名": "巴中","编码": "101270901"},{"市名": "泸州","编码": "101271001"},{"市名": "宜宾","编码": "101271101"},{"市名": "内江","编码": "101271201"},{"市名": "资阳","编码": "101271301"},{"市名": "乐山","编码": "101271401"},{"市名": "眉山","编码": "101271501"},{"市名": "凉山","编码": "101271601"},{"市名": "雅安","编码": "101271701"},{"市名": "甘孜","编码": "101271801"},{"市名": "阿坝","编码": "101271901"},{"市名": "德阳","编码": "101272001"},{"市名": "广元","编码": "101272101"},{"市名": "攀枝花","编码": "101270201"}]},{"省": "宁夏","市": [{"市名": "银川","编码": "101170101"},{"市名": "中卫","编码": "101170501"},{"市名": "固原","编码": "101170401"},{"市名": "石嘴山","编码": "101170201"},{"市名": "吴忠","编码": "101170301"}]},{"省": "青海省","市": [{"市名": "西宁","编码": "101150101"},{"市名": "黄南","编码": "101150301"},{"市名": "海北","编码": "101150801"},{"市名": "果洛","编码": "101150501"},{"市名": "玉树","编码": "101150601"},{"市名": "海西","编码": "101150701"},{"市名": "海东","编码": "101150201"},{"市名": "海南","编码": "101150401"}]},{"省": "山东","市": [{"市名": "济南","编码": "101120101"},{"市名": "潍坊","编码": "101120601"},{"市名": "临沂","编码": "101120901"},{"市名": "菏泽","编码": "101121001"},{"市名": "滨州","编码": "101121101"},{"市名": "东营","编码": "101121201"{"市名": "威海","编码": "101121301" },{"市名": "枣庄","编码": "101121401" },{"市名": "日照","编码": "101121501" },{"市名": "莱芜","编码": "101121601" },{"市名": "聊城","编码": "101121701" },{"市名": "青岛","编码": "101120201" },{"市名": "淄博","编码": "101120301" },{"市名": "德州","编码": "101120401" },{"市名": "烟台","编码": "101120501" },{"市名": "济宁","编码": "101120701" },{"市名": "泰安","编码": "101120801"。
国家气象局提供的天气预报接口(完整Json接口)
"img_title1":" 小雨","img_title2":"晴","img_title3":"晴","img_title4":"晴","img_title5":" 晴",
"img_title6":"阴","img_title7":"多云","img_title8":"阴","img_title9":" 阴","img_title10":"晴",
"img_title11":"晴","img_title12":"多 云","img_title_single":"小雨",
//风向描述
"wind1":"北风4-5级","wind2":"北风3-4级转微 风","wind3":"微风","wind4":"微风","wind5":"微风",
"wind6":"微风","fx1":"北 风","fx2":"北风",
//天气描述(图片序号)
"img1":"7","img2":"0","img3":"0","img4":"99","img5":"0","img6":"2","img7":"1",
简单的动态网页源代码
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
</tr>
</table></td>
<td id=demo12></td>
</tr>
</table>
</div>
<SCRIPT>
var speed=15
demo12.innerHTML=demo11.innerHTML
function Marquee11(){
if(demo12.offsetWidth-demo.scrollLeft<=0)
星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);
</script></div>
2
<SCRIPT language=JavaScript src="js/openfullwin.js"></SCRIPT>
3
<div id="jnkc" class="d12">
<table cellpadding=0 align=left border=1 cellspace="0" bordercolor="#ffffff">
开源免费天气预报接口API以及全国所有地区代码
开源免费天气预报接口API以及全国所有地区代码国家气象局提供的天气预报接口接口地址:对于第三个接口,返回信息比较全面,也是以json格式提供,格式如下{"weatherinfo": {//基本信息;"city":"北京","city_en":"beijing","date_y":"2012年2月16日","date":"","week":"星期四","fchh":"11","cityid":"101010100",//摄氏温度"temp1":"2℃~-7℃","temp2":"1℃~-7℃","temp3":"4℃~-7℃","temp4":"7℃~-5℃","temp5":"5℃~-3℃","temp6":"5℃~-2℃",//华氏温度;"tempF1":"35.6℉~19.4℉","tempF2":"33.8℉~19.4℉","tempF3":"39.2℉~19.4℉","tempF4":"44.6℉~23℉","tempF5":"41℉~26.6℉","tempF6":"41℉~28.4℉",//天气描述;"weather1":"晴","weather2":"晴","weather3":"晴","weather4":"晴转多云","weather5":"多云","weather6":"多云转阴",//天气描述图片序号"img1":"0","img2":"99","img3":"0","img4":"99","img5":"0","img6":"99","img7":"0","img8":"1","img9":"1","img10":"99","img11":"1","img12":"2","img_single":"0",//图片名称;"img_title1":"晴","img_title2":"晴","img_title3":"晴","img_title4":"晴","img_title5":"晴","img_title6":"晴","img_title7":"晴","img_title8":"多云","img_title9":"多云","img_title10":"多云","img_title11":"多云","img_title12":"阴","img_title_single":"晴",//风速描述"wind1":"北风3-4级转微风","wind2":"微风","wind3":"微风","wind4":"微风","wind5":"微风","wind6":"微风",//风速级别描述"fx1":"北风","fx2":"微风","fl1":"3-4级转小于3级","fl2":"小于3级","fl3":"小于3级","fl4":"小于3级","fl5":"小于3级","fl6":"小于3级",//今天穿衣指数;"index":"冷","index_d":"天气冷,建议着棉衣、皮夹克加羊毛衫等冬季服装。
微信天气预报接口代码 (1)
微信天气预报接口代码分享-微信公众平台接口开发(一)微信公众号开放平台,可以利用现在网络上的各种工具接口,为自己的微信公众平台增加亮点。
天气查询,快递查询,手机归属地查询,身份证查询,公交查询,火车查询,健康指数查询,实时翻译(语音),百度百科,百度问答,人品计算,笑话……等接口开发都已经成熟了。
?今天我们先来看看最简单普遍的微信天气预报功能中国天气网天气预报接口(官方接口)请求地址: ?首先我们创建一个类。
保存为:天气预报的处理类<?php"今天:({$info['temp1']}){$info['weather1']}{$info['wind1']}{$info['fl1']}。
\n";$strw .= "明天:({$info['temp2']}){$info['weather2']}{$info['wind2']}{$info['fl2']}。
\n";return $strw;}else{return '没有获取到该城市的天气,请确定输入了正确的城市名称,如\'福州天气\'';}}/*** 验证接受到的数据是否合法* @param string $str 传入的接受到的数据* @return mixed|boolean 有数据返回$code,没有数据返回false;**/private function check($str){气查询(语音)2.快递查询3.手机归属地查询4.身份证查询5.公交查询6.火车查询7.健康指数查询8.实时翻译(语音)9.百度百科10.百度问答11.人品计算12.笑话13.糗事14.谜语15.解梦16.成语接龙17.成语字典18.陪聊19.机器人学习功能。
原生JS实现天气预报
原⽣JS实现天⽓预报本⽂实例为⼤家分享了JS实现天⽓预报的具体代码,供⼤家参考,具体内容如下HTML代码<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport"content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Document</title><link rel="stylesheet" href="tianqi.css" ><link rel="stylesheet" href="iconfont/iconfont.css" ></head><body><!-- 搜索 --><div class="search"><span>Tq</span><form target="sou" id="search_from"><input type="search" placeholder="输⼊搜索的城市"><iframe name="sou" style = "display: none"></iframe></form><div class="search-btn"><img src="images/search.png" alt=""></div></div><!-- 历史记录--><div class="history"><div class="la"><span>历史查询</span><img src="images/more.png" alt=""></div><div class="historys"><!-- 历史记录 --></div><div class="clearbtn">清除历史记录</div></div><!-- 今⽇天⽓ --><div class="information"></div><!-- 天⽓预报 --><div class="forecast"></div><!-- ⽣活指数 --><div class="lifestyle"><h2>⽣活指数</h2><div class="lifestyle-box"><div class="lifestyle-item" data-indexs="0"><i class="iconfont icon-shushidu"></i><span>舒适度指数</span></div><div class="lifestyle-item" data-indexs="1"><i class="iconfont icon-3chuanyixiguan"></i><span>穿⾐指数</span></div><div class="lifestyle-item" data-indexs="2"><i class="iconfont icon-ganmaoyaowu"></i><span>感冒指数</span></div><div class="lifestyle-item" data-indexs="3"><i class="iconfont icon-yundong"></i><span>运动指数</span></div><div class="lifestyle-item" data-indexs="4"><i class="iconfont icon-lvyou"></i><span>旅游指数</span></div><div class="lifestyle-item" data-indexs="5"><i class="iconfont icon-iconset0451"></i><span>紫外线指数</span></div><div class="lifestyle-item" data-indexs="6"><i class="iconfont icon-xiche"></i><span>洗车指数</span></div><div class="lifestyle-item" data-indexs="7"><i class="iconfont icon-kongqiwuranfenxi"></i><span>空⽓污染扩散条件指数</span></div></div></div><!-- ⽣活指数弹窗 --><div class="lifestyle-tc"></div><script src="rem.js"></script><script src="Ajax.js"></script><script src="tianqi.js"></script></body></html>CSS代码* {margin: 0;padding: 0;}ul,li {list-style: none;}body {background-size: 120%;color: white;}.search {position: fixed;width: 100%;height: 0.5rem;background-color: rgba(0,0,0,.0);display: flex;justify-content: space-between;align-items: center;}#search_from {width: 2.8rem;height: 0.4rem;position: relative;}.search > span {width: 0.5rem;font-size: 0.25rem;line-height: 0.5rem;text-align: center;font-family: "Segoe UI Symbol";color: white;}.search #search_from > input {width: 2.8rem;height: 0.4rem;border-radius: 0.1rem;text-indent: 0.1rem;outline: none;position: absolute;border: none;border-bottom: 0.01rem solid white;background-color: rgba(255,255,255,.05);color: white;}.search #search_from > input::-webkit-input-placeholder { color: white;}.search > .search-btn {width: 0.5rem;position: relative;}.search > .search-btn > img {width: 0.25rem;position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);}.history {height: 0.9rem;overflow: auto;background-color: rgba(255,255,255,.05); transition-duration: 0.5s;}.historys {margin-top: 0.8rem;overflow: hidden;}.history .history-item {display: flex;height: 0.4rem;border-bottom: 0.01rem dashed #cccccc; align-items: center;justify-content: space-evenly;}.history .history-item > .history-time {font-size: 0.14rem;}.history .history-item > .history-city {font-size: 0.18rem;}.history .la {height: 0.3rem;display: flex;position: fixed;top: 0.45rem;width: 90%;background-color: rgba(255,255,255,.0); justify-content: space-between;font-size: 0.16rem;border-bottom: 0.01rem solid white;margin: 0.1rem 0.2rem;font-family: 幼圆;line-height: 0.3rem;}.history .la > span {color: white;}.history .la > img {width: 0.2rem;height: 0.2rem;padding: 0.03rem;border: 0.01rem solid #cccccc;border-radius: 0.05rem;}.clearbtn {height: 0.3rem;text-align: center;text-decoration: underline;font-size: 0.2rem;margin-top: 0.1rem;line-height: 0.3rem;}.information {/*background-color: gold;*/}.now {padding-top: 0.2rem;display: flex;flex-direction: column;}.now .city {font-size: 0.4rem;text-align: center;}.now .situation {padding-top: 0.2rem;display: flex;justify-content: space-evenly;font-size: 0.15rem;align-items: center;}.now .situation > img {width: 1rem;height: 1rem;vertical-align: bottom;}.now .temp {display: flex;flex-direction: column;align-items: center;}.now .temp > h3 {font-size: 0.2rem;margin-top: 0.1rem;}.forecast {background-color: rgba(0,0,0,.3);margin: 0 0.2rem;border-radius: 0.1rem;}.forecast-item {height: 0.3rem;display: flex;justify-content: space-between;margin: 0.1rem 0.2rem 0;padding-top: 0.1rem;}.forecast-item:last-of-type {padding-bottom: 0.1rem;}.forecast-item .forecast-situation > img {width: 0.2rem;height: 0.2rem;}.forecast-item .forecast-situation {font-size: 0.16rem;}.forecast-temp {font-size: 0.18rem;}.lifestyle {display: none;margin: 0 0.2rem;background-color: rgba(0,0,0,.3);border-radius: 0.1rem;}.lifestyle > h2 {text-align: center;margin-top: 0.2rem;font-size: 0.2rem;padding-top: 0.15rem;font-family: 幼圆;}.lifestyle .lifestyle-box {display: flex;flex-wrap: wrap;justify-content: space-between;}.lifestyle .lifestyle-box .lifestyle-item {display: flex;flex-direction: column;width: 0.7rem;height: 0.4rem;font-size: 0.14rem;text-align: center;padding-top: 0.1rem;padding-bottom: 0.05rem;}.lifestyle .lifestyle-box .lifestyle-item > i {font-size: 0.2rem;}.lifestyle .lifestyle-box .lifestyle-item > span {white-space: nowrap;text-overflow:ellipsis;overflow:hidden;}.lifestyle-tc {height: 100vh;position: fixed;top: 0;left: 0;background-color: gold;font-family: 幼圆;line-height: 0.4rem;}.lifestyle-tc .fanghui {width: 0.3rem;height: 0.3rem;position: absolute;left: 0.2rem;top: 0.1rem;}.lifestyle-tc .fanghui > img {width: 100%;}.lifestyle-tc > h2 {font-size: 0.3rem;width: 2.2rem;margin: 0.3rem auto 0;text-align: center;}.lifestyle-tc > span {width: 100%;font-size: 0.2rem;margin-top: 1.5rem;display: block;font-weight: 700;text-indent: 0.16rem;}.lifestyle-tc > p {text-indent: 0.32rem;font-size: 0.2rem;}JS代码let searchtext = document.querySelector('.search #search_from > input');let searchbtn = document.querySelector('.search-btn');let information = document.querySelector('.information'); //当前天⽓divlet forecast = document.querySelector(".forecast"); //获取天⽓预报 divlet lifestyle = document.querySelector('.lifestyle');if (localStorage.tq == undefined) { /*如果默认没搜索过就⾃动搜索普宁*/var tqList = [];let defauleCity = "普宁";autorend(defauleCity);} else { /*如果有搜索记录,就⾃动搜索最后⼀次机城市*/var tqList = JSON.parse(localStorage.tq);let endcityName = tqList[tqList.length - 1].cityName;autorend(endcityName);}/* ⾃动渲染⽅法*/function autorend (cityName) {let nowurl = "https:///s6/weather/now?location="+cityName+"&key=26be256aca2c43a7bb7f9a72e0f99a6b";let dailyurl = "https:///s6/weather/forecast?location="+cityName+"&key=26be256aca2c43a7bb7f9a72e0f99a6b"; let lifestyleurl = "https:///s6/weather/lifestyle?location="+cityName+"&key=26be256aca2c43a7bb7f9a72e0f99a6b"; console.log("执⾏⾃动渲染")rendweather(nowurl,cityName,dailyurl,lifestyleurl);}function getTime() {let date = new Date();let year = date.getFullYear();let month = date.getMonth() + 1;let day = date.getDate();let house = date.getHours();house = house < 10 ? '0' + house : house;let minutes = date.getMinutes();minutes = minutes < 10 ? '0' + minutes : minutes;let second = date.getMinutes();second = second < 10 ? '0' + second : second;let time = year + "年 - " + month + "⽉ - " + day + "⽇ - " + house + ":" + minutes + ":" + second;return time;}/*搜索按钮事件*/searchbtn.addEventListener('click',function () {let time = getTime();let cityName = searchtext.value;/*如果输⼊框不为空才执⾏不加这条件会导致传⼊⼀个空的字符串导致历史记录添加到⼀个空的*/if (cityName != "") {let List = {"cityName" : cityName,"time" : time}tqList.push(List);localStorage.tq = JSON.stringify(tqList);rendhistory(tqList);let nowurl = "https:///s6/weather/now?location="+cityName+"&key=26be256aca2c43a7bb7f9a72e0f99a6b";let dailyurl = "https:///s6/weather/forecast?location="+cityName+"&key=26be256aca2c43a7bb7f9a72e0f99a6b"; let lifestyleurl = "https:///s6/weather/lifestyle?location="+cityName+"&key=26be256aca2c43a7bb7f9a72e0f99a6b"; rendweather(nowurl,cityName,dailyurl,lifestyleurl); /*调⽤渲染⽅法*/searchtext.value = "";}});/*⼿机键盘搜索键事件*/document.getElementById('search_from').onsubmit = function () {searchbtn.click();document.activeElement.blur();}/*主页⾯渲染*/function rendweather (nowurl,cityName,dailyurl,lifestyleurl) {/*获取今⽇天⽓信息*/getAjax(nowurl,function (xhr) {let databoj = JSON.parse(xhr.response);let now = databoj.HeWeather6[0].now;if (now == undefined) { /* 如果获取到的为now 说明⽤户输⼊的城市有误*/if (tqList.length > 1) {//如果长度⼤于1 说明之前⽤户正确输⼊过城市tqList.splice(tqList.length - 1 , 1 ); //执⾏删除最后⼀个元素即输⼊错误的城市rendhistory(tqList); // 执⾏历史记录渲染cityName = tqList[tqList.length - 1].cityName; //将城市名赋值为数组最后⼀个元素即最后⼀次正确搜索的城市} else if (tqList.length == 1) { /* 如果长度为1 说明现在为⽌⽤户没输⼊⼀个正确的城市*/cityName = "普宁"; //将城市名赋值为普宁// tqList.splice(tqList.length - 1 , 1 );tqList.pop(); //删除输⼊错误的⽂字rendhistory(tqList); //执⾏历史记录渲染}autorend(cityName); //最后执⾏⾃动渲染} else { //如果以上都没错误说明⽤户输⼊的城市正确正常执⾏代码/* 渲染今⽇天⽓*/information.innerHTML = `<div class="now"><span class="city">${cityName}</span><div class="situation"><img src="https:///cond_icon/${now.cond_code}.png" alt=""> <!-- 天⽓图标 --><h1 class="text">${now.cond_txt}</h1> <!-- 天⽓状况 --><div class="temp"><h3 class="tmp">温度:${now.tmp}℃</h3> <!-- 温度 --><h3 class="fl">体感温度:${now.fl}℃</h3> <!-- 体感温度 --></div></div>`;/*渲染背景图⽚*/let nowcondtxt = now.cond_code;switch(nowcondtxt) {case "101":case "102":case "103":case "104":document.body.style.backgroundImage = "url('images/2.jpg')";break;case "100":case "200":case "201":case "202":case "203":case "204":document.body.style.backgroundImage = "url('images/1.jpg')"; break;case "205":case "206":case "207":case "208":case "209":document.body.style.backgroundImage = "url('images/7.jpg')"; break;case "210":case "211":case "212":case "213":document.body.style.backgroundImage = "url('images/8.jpg')"; break;case "300":case "301":case "302":case "303":case "304":case "305":case "306":case "307":case "308":case "309":case "310":case "311":case "312":case "313":case "314":case "315":case "316":case "317":case "318":case "399":document.body.style.backgroundImage = "url('images/3.jpg')"; break;case "400":case "401":case "402":case "403":case "404":case "405":case "406":case "407":case "408":document.body.style.backgroundImage = "url('images/4.jpg')"; break;case "500":case "501":case "502":case "503":case "504":case "505":case "506":case "507":case "508":document.body.style.backgroundImage = "url('images/5.jpg')"; break;case "509":case "510":case "511":case "512":case "513":case "514":case "515":document.body.style.backgroundImage = "url('images/6.jpg')"; break;default:document.body.style.backgroundImage = "url('images/9.jpg')";}/*获取天⽓预告信息*/getAjax(dailyurl,function (xhr) {forecast.innerHTML = ""; /*清除之前的渲染*/let databoj = JSON.parse(xhr.response);let daily = databoj.HeWeather6[0].daily_forecast;daily.forEach(function (item,index) {/*如果当天天⽓早上和晚上⼀样就输出⼀个如果不⼀样就早上转晚上(天⽓类型)*/var txt = item.cond_txt_d == item.cond_txt_n ? item.cond_txt_d : item.cond_txt_d + "转" + item.cond_txt_n; let date = '今天'; /*默认今天*/if (index == 1) { /* 第⼆个赋值为明天*/date = "明天";} else if (index == 2) { /* 第三个赋值为后天*/date = "后天";}/*渲染天⽓预报*/forecast.innerHTML += `<div class="nowday forecast-item"><div class="forecast-situation"><img src="https:///cond_icon/${item.cond_code_d}.png" alt="">${date} * <span class="txt">${txt}</span></div><div class="forecast-temp"><span class="max">${item.tmp_max}°/</span><span class="min">${item.tmp_min}°</span></div></div>`;})});lifestyle.style.display = 'block'; /*显⽰⽣活指数模板*//*获取⽣活指数*/getAjax(lifestyleurl,function (xhr) {let databoj = JSON.parse(xhr.response);let lifestyle = databoj.HeWeather6[0].lifestyle;lifestyleclick(lifestyle); /*调⽤⽣活指数渲染⽅法*/});}});}/*⽣活指数渲染⽅法*/let lifestyleitem = document.querySelectorAll('.lifestyle-item');function lifestyleclick (lifestyle) {for (let j = 0; j < lifestyleitem.length; j ++) {lifestyleitem[j].onclick = function () {let index = lifestyleitem[j].dataset.indexs;let li = lifestyle[index];let lifestyletc = document.querySelector('.lifestyle-tc');lifestyletc.innerHTML = `<div class="fanghui"><img src="images/fanghui.png" alt=""></div><h2>${lifestyleitem[j].children[1].childNodes[0].data}</h2><span>${li.brf}</span><p>"${li.txt}"</p>`;lifestyletc.style.display = 'block';/*关闭按钮*/let fanghuibtn = document.querySelector('.fanghui');console.log(fanghuibtn);fanghuibtn.onclick = function () {lifestyletc.style.display = 'none';}}}}//历史记录事件let historys = document.querySelector('.historys');function rendhistory(tqList) {historys.innerHTML = ""; /*每次执⾏历史记录渲染都清除之前的记录防⽌出现重复*/tqList.forEach(function (item,index) {/*将历史记录写⼊*/historys.innerHTML += `<div class="history-item" data-indexs="${index}"><span class="history-time">${item.time}</span><span class="history-city">${item.cityName}</span></div>`;})/*获取历史记录div 添加点击事件* 点击后跳转点击的城市* */let historyitem = document.querySelectorAll('.history-item');for (let j = 0; j < historyitem.length; j ++) {historyitem[j].onclick = function() {let index = historyitem[j].dataset.indexs;let thecityName = tqList[index].cityName;let time = getTime();let List = {"cityName" : thecityName,"time" : time}tqList.push(List);localStorage.tq = JSON.stringify(tqList);rendhistory(tqList);autorend(thecityName);}}}rendhistory(tqList);xiala();//下拉菜单事件function xiala () {let historybtn = document.querySelector('.la > img');let historyDiv = document.querySelector('.history');let clearhistory = document.querySelector('.clearbtn');let flag = true;historybtn.addEventListener('click',function () {if (flag) {flag = false;historybtn.style.backgroundColor = "rgba(0,0,0,.3)";let height = (tqList.length * 0.4) + 1.7;historyDiv.style.height = height + 'rem';} else {flag = true;historybtn.style.backgroundColor = "rgba(0,0,0,.0)";historyDiv.style.height = '0.9rem';}});clearhistory.addEventListener('click',function () { /*清除历史记录事件*/localStorage.removeItem('tq'); /*删除本地存储*/tqList = []; /*将数组清空*/rendhistory(tqList); /*渲染历史记录*/historybtn.click(); /*执⾏下拉按钮点击*/});searchtext.addEventListener('click',function () { //点击输⼊框如果下拉菜单打开就关闭if (!flag) {historybtn.click();}});}以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。
使用JS调用腾讯接口获取天气
使⽤JS调⽤腾讯接⼝获取天⽓想做个直接通过JS获取某个城市的天⽓。
本来想通过直接调⽤中国⽓象⽹的接⼝:1function Weather() {};23 Weather.prototype = {45 getWeather: function (city, callback) {6var that = this,7 cities = Weather.cityParse(),8 code = cities[city] ? cities[city] : 125, // 默认使⽤北京城市9 url = '/weather/inc/minisite2_' + code + '.js'; // 腾讯天⽓API jsonp接⼝1011this.createJsonp(url, function (para) {12var desc = that.weatherParse(para); // 通过jsonp获取天⽓相关信息13 callback(desc);14 });15 },16 // jsonp17 createJsonp: function (url, callback) {18var script = document.createElement('script');19 script.type = 'text/javascript';20 script.src = url;2122 script.onreadystatechange = function () {23if (script.readyState === 'loaded' || script.readyState === 'complete') {24 callback(__minisite2__weather__);2526 script.onreadystatechange = null;27 script.onload = null;28 }29 };3031 script.onload = function () {32 callback(__minisite2__weather__);33 script.onreadystatechange = null;34 script.onload = null;35 };3637 document.body.appendChild(script);38 },3940 weatherParse: function (para) {4142try {43var params = para.split(' ');44var weather = {45 city: params[0],46 temperature: params[1],47 range: params[2],48 describe: params[3]49 };5051return weather;52 } catch (e) {5354 }55 }56 };57 // 将城市及其对应代码解析成hash形式58 Weather.cityParse = function () {59var cities = {},60 prop,62 item;6364for (prop in this.city) {65 item = Weather.city[prop]; 66for (var city in item) {67if (city !== '_') {68 code = item[city];69 city = city.slice(0, -1);70 cities[city] = code;71 }72 }73 }7475return cities;76 };7778 Weather.city = {79 "北京市": {80 "_": 125,81 "北京市": 12582 },83 "上海市": {84 "_": 252,85 "上海市": 25286 },87 "天津市": {88 "_": 127,89 "天津市": 127,90 "塘沽区": 13291 },92 "重庆市" : {93 "_": 212,94 "奉节区": 201,95 "重庆市": 212,96 "涪陵区": 21397 },98 "⾹港": {99 "_": 1,100 "⾹港": 1101 },102 "澳门": {103 "_": 2,104 "澳门": 2105 },106 "台湾省": {107 "_": 280,108 "台北市": 280109 },110 "云南省": {111 "_": 179,112 "昭通市": 173,113 "丽江市": 174,114 "曲靖市": 175,115 "保⼭市": 176,116 "⼤理州": 177,117 "楚雄州": 178,118 "昆明市": 179,119 "瑞丽市": 180,120 "⽟溪市": 181,121 "临沧市": 182,122 "思茅市": 184,123 "红河州": 185,124 "⽂⼭州": 369,125 "西双版纳州": 370, 126 "德宏州": 371,127 "怒江州": 372,128 "迪庆州": 373130 "内蒙古": {131 "_": 69,132 "呼伦贝尔市": 4,133 "兴安盟": 7,134 "锡林郭勒盟": 16,135 "巴彦淖尔市": 63,136 "包头市": 64,137 "呼和浩特市": 69,138 "锡林浩特市": 99,139 "通辽市": 101,140 "⾚峰市": 106,141 "乌海市": 382,142 "鄂尔多斯市": 383,143 "乌兰察布市": 384144 }145 };146 // 主要是些事件处理相关的⽅法包装147var Util = {148 addEvent: function (element, type, handler) {149if (element.addEventListener) {150 element.addEventListener(type, handler, false);151 } else if (element.attachEvent) {152 element.attachEvent('on' + type, handler);153 }154 },155156 getEvent: function (event) {157return event || window.event;158 },159160 getTarget: function (event) {161return event.target || event.srcElement;162 },163164 getComputedStyle: function (element) {165if (element.currentStyle) {166return element.currentStyle;167 } else {168return document.defaultView.getComputedStyle(element, null);169 }170 },171172 getBoundingClientRect: function (element) {173var scrollTop = document.documentElement.scrollTop;174var scrollLeft = document.documentElement.scrollLeft;175176if (element.getBoundingClientRect) {177if (typeof arguments.callee.offset != 'number') {178var temp = document.createElement('div');179 temp.style.cssText = 'position: absolute; left: 0; top: 0;';180 document.body.appendChild(temp);181 arguments.callee.offset = -temp.getBoundingClientRect().top - scrollTop; 182 document.body.removeChild(temp);183 temp = null;184 }185186var rect = element.getBoundingClientRect();187var offset = arguments.callee.offset;188189return {190 left: rect.left + offset,191 rigth: rect.right + offset,192 top: rect.top + offset,193 bottom: rect.bottom + offset194 };195 } else {196var offset = this.getElementOffset(element);197198return {199 left: offset.left - scrollLeft,200 right: offset.left + element.offsetWidth - scrollLeft,201 top: offset.top - scrollTop,202 bottom: offset.top + element.offsetWidth - scrollTop203 };204 }205 },206207 getElementOffset: function (element) {208var actualLeft = element.offsetLeft;209var actualTop = element.offsetTop;210var current = element.offsetParent;211212while (current !== null) {213 actualLeft += current.offsetLeft;214 actualTop += current.actualTop;215 current = current.offsetParent;216 }217218return {219 left: actualLeft,220 top: actualTop221 };222 }223 };HTML页⾯的代码如下:1<!DOCTYPE html>2<html>3 <head>4 <title>weather</title>5 <meta http-equiv="Content-Type" content="text/html; charset=gbk;" />6 <style type="text/css" >7 #city {8 width: 150px;9 heigth: 30px;10}11 #inputCity {12 position: absolute;13 width: 130px;14 heigth: 25px;15}16 </style>17 </head>18 <body>19 <h1>Weather</h1>20 <fieldset>21 <legend> 获取时间 </legend>22 <label for="city">请选择城市:</label>23 <select name="city" id="city">24 <!--<option selected="selected"></option>-->25 <option>北京</option>26 <option>⼤连</option>27 <option>福州</option>28 </select>29 <input type="text" id="inputCity" value = '请输⼊或选择城市' />30 <input type="button" id="getWeather" value="获取天⽓" />31 </fieldset>32 <div id="showWeather">3334 </div>35 <script type="text/javascript" src="weather.js"></script>36 <script>37 (function(){112113 var city = document.getElementById('city');114 var getWeather = document.getElementById('getWeather');115 var inputCity = document.getElementById('inputCity');116 var tip = inputCity.value;117 var cities = Weather.cityParse();118119120 var pos = Util.getBoundingClientRect(city);121 var volumn = Util.getComputedStyle(city);122 console.log(pos);123124 // 设置输⼊⽂本框的位置125 inputCity.style.left = pos.left + 'px';126 inputCity.style.top = pos.top + 'px';127128 Util.addEvent(city, 'change', function (event) {129 var value = city.options[city.selectedIndex].value;130 inputCity.value = value;131});132133 Util.addEvent(inputCity, 'focus', function (event) {134 Util.getTarget(event).select();135});136137 Util.addEvent(inputCity, 'change', function () {138139 var city = inputCity.value;140 if ( city.slice(-1) === '市') {141 city = city.slice(0, -1);142}143 if ( city && !cities[city] ) {144 alert('⽬前⽆法获取' + city + '的天⽓,请输⼊其它城市');145} else if ( !city ) {146 inputCity.value = tip;147}148149 });150151 Util.addEvent(getWeather, 'click', function (event) {152 var city = inputCity.value;153 if ( city && !cities[city] ) {154 alert('⽬前⽆法获取' + city + '的天⽓,请输⼊其它城市');155 return false;156}157 // 天⽓获取158 (new Weather()).getWeather(city, function(param){159160 var showWeather = document.getElementById('showWeather'); 161 showWeather.innerHTML = '城市:' + param.city +162 '<br /> 温度:' + param.temperature +163 '<br /> 温度范围:' + param.range +164 '<br /> 描述:' + param.describe;165});166 });168169 })();170 </script>171 </body>172</html>。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
还有更多说明请参阅压缩包内的说明。
分别是
weather
uisy
onEvent
weather系统核心对象。处理了向新浪请求数据,天气预报皮肤,揣测天气预报对应的图片,页面的输出已经系统帮助的等功能。
使用方法:
该程序是基于jquery 1.32 和 daluzai JS函数库 1.3 开发的,所以在使用前请检测网站是否拥有jquery和daluzai函数库。 确认无误后那么就可以初始化大陆仔天气预报了
:
摘要:脚本资源,Ajax/JavaScript,天气预报
一个纯JS版的天气预报,调用了新浪的天气预报接口,支持根据用户IP来显示当地的天气预报(使用了魔镜的 API),支持用户搜索中国和国外城市的天气预报,将能够查询未来两天的天气情况。
本JS版天气预报的核心程序:
Weather.js 共有三个对象: Leabharlann //创建天气预报核心对象
var weather_=new weather();
接着,配置将要使用的天气预报风格:(系统默认使用QQ的风格)
//设置样式
weather_.getStyle(‘qq‘);
大陆仔天气预报支持两套风格:QQ风格和未名风格。
QQ风格将和QQ天气预报一样的皮肤和显示方式,