web前端|js教程
Ajax,api,报的
web前端-js教程预览图(比较简单粗糙)
酒店预订系统php源码,mac系统运行vscode,ubuntu ttf下载,tomcat 7 重启命令,c语言中使用sqlite3,爬虫鱼缸,php认证工程师,保定seo服务费用,网站随机标签,织梦模板小偷lzw
程序源码网站,ubuntu 关机爆音,服务器商部署tomcat,晚上爬虫的图片,php人员外包多少钱,重庆公司seolzw
聚合数据全国天气预报接口:/docs/api/id/39
故事网站源码,Ubuntu 18 改中文,邯郸市爬虫,php 靶场,高唐seo报价lzw
接口地址:/weather/index
支持格式:json/xml
请求方式:get
请求示例:/weather/index?format=2&cityname=%E8%8B%8F%E5%B7%9E&key=您申请的KEY
调用样例及调试工具:API测试工具
请求参数说明:
名称 类型 必填 说明
cityname string Y 城市名或城市ID,如:”苏州”,需要utf8 urlencode
dtype string N 返回数据格式:json或xml,默认json
format int N 未来6天预报(future)两种返回格式,1或2,默认1
key string Y 你申请的key
HTML部分代码:
JavaScript部分:
/** 1.输入城市名* 2,点击的时候发送请求* 3.响应成功渲染页面* */$(#search).on(click,function(){var city = $(#city).val()||北京;$citycode=urlencode(city);url=/weather/index?format=2&cityname=+$citycode+&key=c82727e986a4f6cfc6ba1984f1f9183a;$.ajax({url: url,dataType: "jsonp",type:"get",data:{location:city},success:function(data){var sk = data.result.sk;var today = data.result.today;var futur = data.result.future;var fut = "日期温度天气风向";$(#mufeng).html("
" + 当前: + sk.temp + ℃ , + sk.wind_direction + sk.wind_strength + , + 空气湿度 + sk.humidity + , 更新时间 + sk.time + "
" + today.city + 今天是: + today.date_y + + today.week + , + today.temperature + , + today.weather + , + today.wind + "");$(#future).html("
" + 未来: + futur[0].temperature+ ℃ , + futur[0].weather + futur[0].wind + , + , 更新时间 + futur[0].week+futur[0].date + "
" + today.city + "");} });});function urlencode (str) { str = (str + \).toString(); return encodeURIComponent(str).replace(/!/g, \%21).replace(//g, \%27).replace(/\(/g, \%28). replace(/\)/g, \%29).replace(/\*/g, \%2A).replace(/%20/g, +); } })