您现在的位置是: 首页 > 长期预报 长期预报
天气预报代码_python天气预报代码
zmhk 2024-06-06 人已围观
简介天气预报代码_python天气预报代码 下面,我将以我的观点和见解来回答大家关于天气预报代码的问题,希望我的回答能够帮助到大家。现在,让我们开始聊一聊天气预报代码的话题。1.????Ԥ??????2.
下面,我将以我的观点和见解来回答大家关于天气预报代码的问题,希望我的回答能够帮助到大家。现在,让我们开始聊一聊天气预报代码的话题。
1.????Ԥ??????
2.求横向不滚动宁波地区的天气预报代码? 急!高分回报!
3.求天气预报代码
4.ASP.NET实现天气预报
????Ԥ??????
<iframe width="420" scrolling="no" height="60" frameborder="0" allowtransparency="true" src="/weather/101190801.shtml "
width="245" height="110" marginwidth="0" marginheight="0" hspace="0" vspace="0"
frameborder="0" scrolling="no"></iframe>
那个连接链接到“中国天气”网。
需要其他城市的天气的时,就替换101190801这个字符串。比如我们搜索到上海,看见url是这样:/weather/101020100.shtml
插入天气预报,效果如下:
求天气预报代码
在你的网页中实现为个天气预报的功能,在网页适当位置中加入如下代码:
<iframe allowtransparency=true name=weather src=酒嘉市场信息网
这是泰安的天气预报代码,看你需要那种样式
样式一代码:<iframe src="/iframe/weather/" + code + "_w.html ");
request.Method = "Get";
//request.Timeout = 1;
request.ContentType = "application/x-www-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;
}
}
好了,今天关于“天气预报代码”的话题就讲到这里了。希望大家能够对“天气预报代码”有更深入的认识,并从我的回答中得到一些启示。如果您有任何问题或需要进一步的信息,请随时告诉我。