您现在的位置是: 首页 > 天气温度 天气温度
html天气预报代码_.net天气预报代码
tamoadmin 2024-09-09 人已围观
简介1.c#窗体程序中怎么获取到从接口中得到的信息?天气预报://m.weather.cn/data/101230101.html2.ASP.NET实现天气预报3.android端免费获取天气信息的服务器接口有么4.我想知道大连未来五天的天气,最好是发过来你信息的来源的名称:265天气根据IP自动获得当地的天气情况代码:<iframe src="://weather.265/weather.ht
1.c#窗体程序中怎么获取到从接口中得到的信息?天气预报://m.weather.cn/data/101230101.html
2.ASP.NET实现天气预报
3.android端免费获取天气信息的服务器接口有么
4.我想知道大连未来五天的天气,最好是发过来你信息的来源的
名称:265天气根据IP自动获得当地的天气情况
代码:<iframe src="://weather.265/weather.htm" width="168" height="54" frameborder="no" border="0" marginwidth="0&quoat; marginheight="0" scrolling="no"></iframe>
名称:QQ天气预报代码(一)
代码 :<iframe width="145" height="130" border="0" align="center" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" src="://minisite.qq/Weather/news_new.html" allowTransparency="true"></iframe>
说明 :这种适合于在网页的边栏插入。但一个缺点是,上面的4个城市是既定的,无法改成别的。插 入时,选好网页上的位置,直接将左栏的源代码全部拷进去就行了
名称:QQ天气预报代码(二)
代码 :<IFRAME ID='ifm2' WIDTH='189' HEIGHT='190' ALIGN='CENTER' MARGINWIDTH='0' MARGINHEIGHT='0' HSPACE='0' VSPACE='0' FRAMEBORDER='0' SCROLLING='NO' SRC='://weather.qq/inc/ss258.htm'></IFRAME>
说明 :这种 也适合于在网页的边栏插入。上面 的城市可以自定,比如厦门可改成别的。定制的方法是修改我代码中标红的数字,从1开始代表“香 港”开始,每个数字都代表一个城市,厦门是287,具体要哪个城市自己找一下罢。
名称:新浪天气预报代码
代码 :<IFRAME ID='ifm2' WIDTH='260' HEIGHT='70' ALIGN='CENTER' MARGINWIDTH='0' MARGINHEIGHT='0' HSPACE='0' VSPACE='0' FRAMEBORDER='0' SCROLLING='NO' src="://news.sina.cn/iframe/weather/130101.html"></iframe>
说明 :这种适合于在网页的头栏插入。上面的城市可以自定,比如 石家庄可改成别的。
名称:QQ天气预报代码(三)
代码 :<iframe width="469" height="218" border="0" align="center" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" src="://news.qq/cgi-bin/news_weather_search?city=厦门" allowTransparency="true"></iframe>
说明 :这种适合于在网页的正栏插入。上面的城市可以自定,比如厦门可改成别的。定制的方法是修改我代码中标红的 名称。这里比较简单,直接用汉字改就行了。比如是福州的,你就直接把“厦门”改成福州就行。
名称:QQ天气预报代码(四)
代码 :<iframe width=160 height=230 frameborder=0 scrolling=NO src=://news.qq/cgi-bin/news_qq_search?city=南昌></iframe>
名称:QQ天气预报代码(五)
代码 :<iframe src="://news.qq/cgi-bin/news_qq_search?city=南昌" frameborder="0" width="160" scrolling="no" height="230"></iframe>
c#窗体程序中怎么获取到从接口中得到的信息?天气预报://m.weather.cn/data/101230101.html
首先登入百度账号
将鼠标移动到天气上,就会出现未来几天天气的详细情况,点击右上角的设置
就可以选择省份
接着选择城市,一般省会在第一个,其他的城市按照开头名字的第一个字母排序
可以勾选极端天气提醒,在出现极端天气的时候,登入百度首页就可以收到提醒
然后点击保存
就可以看到首页天气设置好了
代码看中国天气网里面的插件
ASP.NET实现天气预报
你这个不是接口,只是个网页地址。
我找到另外一个天气预报的接口:
://.webxml.cn/WebServices/WeatherWebService.asmx
只要在项目中添加Web引用:
按照这个做:
然后人就可以实例化这个对象:
调用对应的方法就可以获取接口中的信息了。
直接在IE或其它浏览器中打开这接口网址:
://.webxml.cn/WebServices/WeatherWebService.asmx
可以看到那些方法的使用说明。
还是不会就不应该了。为了这15分,可以加我好友再问。
android端免费获取天气信息的服务器接口有么
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Net;
using System.IO;
using System.Collections;
/// <summary>
/// Weather 的摘要说明
/// </summary>
public class Weather
{
public Weather()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static string ConvertCodeByCity(string City)
{
string Code = "";
switch (City)
{
case "北京":
Code = "110100";
break;
default:
break;
}
return Code;
}
public static ArrayList GetWeather(string code)
{
/*
[0] "北京 "string
[1] "雷阵雨 "string
[2] "9℃" string
[3] "29℃"string
[4] "小于3级"string
*/
string html = "";
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("://weather.sina.cn/iframe/weather/" + code + "_w.html ");
request.Method = "Get";
//request.Timeout = 1;
request.ContentType = "lication/x--form-urlencoded ";
WebResponse response = request.GetResponse();
Stream s = response.GetResponseStream();
StreamReader sr = new StreamReader(s, System.Text.Encoding.GetEncoding("GB2312"));
html = sr.ReadToEnd();
s.Close();
sr.Close();
}
catch (Exception err)
{
throw new Exception("访问地址出错~~~ ");
}
int count = html.Length;
int starIndex = html.IndexOf("<table ", 0, count);
int endIndex = html.IndexOf("</table>", starIndex, count - starIndex);
html = html.Substring(starIndex, endIndex - starIndex + 8);
//得到城市
int cityStartIndex = html.IndexOf("<b>", 0, html.Length);
int cityEndIndex = html.IndexOf("</b>", 0, html.Length);
string City = html.Substring(cityStartIndex + 3, cityEndIndex - cityStartIndex - 3);
//得到天气
int weatherStartIndex = html.IndexOf("<b>", cityEndIndex);
int weatherEndIndex = html.IndexOf("</b>", weatherStartIndex);
string Weather = html.Substring(weatherStartIndex + 3, weatherEndIndex - weatherStartIndex - 3);
//得到温度
int temperatureStartIndex = html.IndexOf("<b", weatherEndIndex);
int temperatureEndIndex = html.IndexOf("</b>", weatherEndIndex + 3);
string Temperature = html.Substring(temperatureStartIndex + 21, temperatureEndIndex - temperatureStartIndex - 21);
int int1 = Temperature.IndexOf("℃", 0);
int int2 = Temperature.IndexOf("~", 0);
int int3 = Temperature.IndexOf("℃", int2);
string MinTemperature = Temperature.Substring(int2 + 1, int3 - int2);
string MaxTemperature = Temperature.Substring(0, int2 - int1 + 2);
//得到风力
int windforceStartIndex = html.IndexOf("风力:", temperatureEndIndex);
int windforceEndIndex = html.IndexOf("<br>", windforceStartIndex);
string Windforce = html.Substring(windforceStartIndex + 3, windforceEndIndex - windforceStartIndex - 3);
if (Windforce.Contains("小于") && (!Windforce.Contains("等于"))) //判断风力是否含有"小于"或"小于等于"字样将,如果有的话,将其替换为2-
{
//Windforce = Windforce.Replace("小于", "2-");
string strWindforce = Windforce.Substring(2, Windforce.Length - 3);
int minWindforce = Int32.Parse(strWindforce) - 1;
Windforce = Windforce.Replace("小于", minWindforce.ToString() + "-");
}
else if (Windforce.Contains("小于等于"))
{
string strWindforce = Windforce.Substring(4, Windforce.Length - 5);
int minWindforce = Int32.Parse(strWindforce) - 1;
Windforce = Windforce.Replace("小于等于", minWindforce.ToString() + "-");
}
ArrayList al = new ArrayList();
al.Add(City);
al.Add(Weather);
al.Add(MinTemperature);
al.Add(MaxTemperature);
al.Add(Windforce);
return al;
}
}
我想知道大连未来五天的天气,最好是发过来你信息的来源的
中国国家气象局提供了获取所在城市天气预报信息接口。通过这个接口,我们就可以获取天气信息了。
关于获取天气预报的实例参考android学习手册,里面有源码。android学习手册包含9个章节,108个例子,源码文档随便看,例子都是可交互,可运行,源码用android studio目录结构,高亮显示代码,文档都用文档结构图显示,可以快速定位。360手机助手中下载,图标上有贝壳
中国国家气象局天气预报接口总共提供了三个:
://.weather.cn/data/sk/101010100.html
://.weather.cn/data/cityinfo/101010100.html
://m.weather.cn/data/101010100.html
注:上面接口2014.3.4日已不再更新。换成这个:://m.weather.cn/atad/101230201.html。各位看34楼。在此感谢tdwll和黄晓佳cobish。
最详细的信息来自第三个接口。上面url中的101010100是城市代码,这里是北京的城市代码。只需要改变城市代码,就可以得到所在城市的天气信息。笔者在福州,所以选择的城市代码是福州101230101。
在浏览器上输入url:://m.weather.cn/data/101230101.html得到信息,天气信息是json的数据格式,数据如下:
{"weatherinfo":{"city":"福州","city_en":"fuzhou","date_y":"2012年5月14日","date":"","week":"星期一","fchh":"08","cityid":"101230101","temp1":"29℃~23℃","temp2":"26℃~20℃","temp3":"24℃~20℃","temp4":"25℃~20℃","temp5":"24℃~21℃","temp6":"25℃~22℃","tempF1":"84.2℉~73.4℉","tempF2":"78.8℉~68℉","tempF3":"75.2℉~68℉","tempF4":"77℉~68℉","tempF5":"75.2℉~69.8℉","tempF6":"77℉~71.6℉","weather1":"阵雨转中雨","weather2":"中雨转小雨","weather3":"小雨","weather4":"小雨","weather5":"小雨转阵雨","weather6":"阵雨转小雨","img1":"3","img2":"8","img3":"8","img4":"7","img5":"7","img6":"99","img7":"7","img8":"99","img9":"7","img10":"3","img11":"3","img12":"7","img_single":"3","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":"微风","wind2":"微风","wind3":"微风","wind4":"微风","wind5":"微风","wind6":"微风","fx1":"微风","fx2":"微风","fl1":"小于3级","fl2":"小于3级","fl3":"小于3级","fl4":"小于3级","fl5":"小于3级","fl6":"小于3级","index":"热","index_d":"天气较热,建议着短裙、短裤、短套装、T恤等夏季服装。年老体弱者宜着长袖衬衫和单裤。","index48":"暖","index48_d":"较凉爽,建议着长袖衬衫加单裤等春秋过渡装。年老体弱者宜着针织长袖衬衫、马甲和长裤。","index_uv":"弱","index48_uv":"最弱","index_xc":"不宜","index_tr":"适宜","index_co":"较不舒适","st1":"27","st2":"21","st3":"24","st4":"18","st5":"22","st6":"18","index_cl":"较不宜","index_ls":"不太适宜","index_ag":"不易发"}}
我们可以解析json数据去得到自己想用的天气信息。
天气信息解释:
[html] view plain copy print?
{?
"weatherinfo":{?
<!--?基本信息?-->?
"city":"福州",?
"city_en":"fuzhou",?
"date_y":"2012年5月14日",?
"date":"",?
"week":"星期一",?
"fchh":"08",?
"cityid":"101230101",?
<!--?从今天开始到第六天的每天的天气情况,这里的温度是摄氏温度?-->?
"temp1":"29℃~23℃","temp2":"26℃~20℃","temp3":"24℃~20℃","temp4":"25℃~20℃","temp5":"24℃~21℃","temp6":"25℃~22℃",?
<!--?从今天开始到第六天的每天的天气情况,这里的温度是华氏温度?-->?
"tempF1":"84.2℉~73.4℉","tempF2":"78.8℉~68℉","tempF3":"75.2℉~68℉","tempF4":"77℉~68℉","tempF5":"75.2℉~69.8℉","tempF6":"77℉~71.6℉",?
<!--?天气描述?-->?
"weather1":"阵雨转中雨","weather2":"中雨转小雨","weather3":"小雨","weather4":"小雨","weather5":"小雨转阵雨","weather6":"阵雨转小雨",?
<!--?天气描述序号?-->?
"img1":"3","img2":"8","img3":"8","img4":"7","img5":"7","img6":"99","img7":"7","img8":"99","img9":"7","img10":"3","img11":"3","img12":"7","img_single":"3",?
<!--?名称?-->?
"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":"微风","wind2":"微风","wind3":"微风","wind4":"微风","wind5":"微风","wind6":"微风","fx1":"微风","fx2":"微风",?
<!--?风速级别描述?-->?
"fl1":"小于3级","fl2":"小于3级","fl3":"小于3级","fl4":"小于3级","fl5":"小于3级","fl6":"小于3级",?
<!--?今天穿衣指数?-->?
"index":"热",?
"index_d":"天气较热,建议着短裙、短裤、短套装、T恤等夏季服装。年老体弱者宜着长袖衬衫和单裤。",?
<!--?48小时穿衣指数?-->?
"index48":"暖","index48_d":"较凉爽,建议着长袖衬衫加单裤等春秋过渡装。年老体弱者宜着针织长袖衬衫、马甲和长裤。",?
<!--?紫外线及48小时紫外线?-->?
"index_uv":"弱","index48_uv":"最弱",?
<!--?洗车?-->?
"index_xc":"不宜",?
<!--?旅游?-->?
"index_tr":"适宜",、?
<!--?舒适指数?-->?
"index_co":"较不舒适",?
"st1":"27","st2":"21","st3":"24","st4":"18","st5":"22","st6":"18",?
<!--?晨练?-->?
"index_cl":"较不宜",?
<!--?晾晒?-->?
"index_ls":"不太适宜",?
<!--?过敏?-->?
"index_ag":"不易发"?
}?
}?
{
"weatherinfo":{
<!-- 基本信息 -->
"city":"福州",
"city_en":"fuzhou",
"date_y":"2012年5月14日",
"date":"",
"week":"星期一",
"fchh":"08",
"cityid":"101230101",
<!-- 从今天开始到第六天的每天的天气情况,这里的温度是摄氏温度 -->
"temp1":"29℃~23℃","temp2":"26℃~20℃","temp3":"24℃~20℃","temp4":"25℃~20℃","temp5":"24℃~21℃","temp6":"25℃~22℃",
<!-- 从今天开始到第六天的每天的天气情况,这里的温度是华氏温度 -->
"tempF1":"84.2℉~73.4℉","tempF2":"78.8℉~68℉","tempF3":"75.2℉~68℉","tempF4":"77℉~68℉","tempF5":"75.2℉~69.8℉","tempF6":"77℉~71.6℉",
<!-- 天气描述 -->
"weather1":"阵雨转中雨","weather2":"中雨转小雨","weather3":"小雨","weather4":"小雨","weather5":"小雨转阵雨","weather6":"阵雨转小雨",
<!-- 天气描述序号 -->
"img1":"3","img2":"8","img3":"8","img4":"7","img5":"7","img6":"99","img7":"7","img8":"99","img9":"7","img10":"3","img11":"3","img12":"7","img_single":"3",
<!-- 名称 -->
"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":"微风","wind2":"微风","wind3":"微风","wind4":"微风","wind5":"微风","wind6":"微风","fx1":"微风","fx2":"微风",
<!-- 风速级别描述 -->
"fl1":"小于3级","fl2":"小于3级","fl3":"小于3级","fl4":"小于3级","fl5":"小于3级","fl6":"小于3级",
<!-- 今天穿衣指数 -->
"index":"热",
"index_d":"天气较热,建议着短裙、短裤、短套装、T恤等夏季服装。年老体弱者宜着长袖衬衫和单裤。",
<!-- 48小时穿衣指数 -->
"index48":"暖","index48_d":"较凉爽,建议着长袖衬衫加单裤等春秋过渡装。年老体弱者宜着针织长袖衬衫、马甲和长裤。",
<!-- 紫外线及48小时紫外线 -->
"index_uv":"弱","index48_uv":"最弱",
<!-- 洗车 -->
"index_xc":"不宜",
<!-- 旅游 -->
"index_tr":"适宜",、
<!-- 舒适指数 -->
"index_co":"较不舒适",
"st1":"27","st2":"21","st3":"24","st4":"18","st5":"22","st6":"18",
<!-- 晨练 -->
"index_cl":"较不宜",
<!-- 晾晒 -->
"index_ls":"不太适宜",
<!-- 过敏 -->
"index_ag":"不易发"
}
}
15日星期三 多云转阵雨高温:12℃低温:6℃南风4-5级转东北风5-6级16日星期四
晴高温:14℃低温:5℃北风5-6级17日星期五
晴高温:16℃低温:7℃西南风4-5级18日星期六
晴高温:17℃低温:8℃南风5-6级19日星期日
多云转中雨高温:20℃低温:13℃微风20日星期一
中雨转晴高温:22℃低温:12℃微风转北风3-4级