ASP.NET的實(shí)時(shí)天氣及24小時(shí)天氣預(yù)報(bào)(C#) 修改其中的url獲得其他城市的天氣情況 如廣州為: http://weather " /> 久久久久久亚洲精品,欧美福利视频,啪啪网视频

四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

ASP.net(c#)打造24小時(shí)天氣預(yù)報(bào)及實(shí)時(shí)天氣

本文詳細(xì)介紹關(guān)于ASP.NET的實(shí)時(shí)天氣及24小時(shí)天氣預(yù)報(bào)
修改其中的url獲得其他城市的天氣情況的文章專題。


ASP.NET的實(shí)時(shí)天氣及24小時(shí)天氣預(yù)報(bào)(C#) 
修改其中的url獲得其他城市的天氣情況 
如廣州為: 
http://weather.yahoo.com
/forecast/CHXX0037_c.html 
注意僅適用于獲得yahoo上的天氣預(yù)報(bào) 
GetWeather.ASP
-----------------------------------  

復(fù)制代碼 代碼如下:<%@ Page language="c#" Codebehind="GetWeather.ASPx.cs" AutoEventWireup="false" Inherits="test.GetWeather" %>  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >  
<HTML>  
<HEAD>  
<title>GetWeather</title>  
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">  
<meta name="CODE_LANGUAGE" Content="C#">  
<meta name="vs_defaultClientScript" content="JavaScript">  
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">  
</HEAD>  
<body>  
<form id="GetWeather" method="post" runat="server">  
<FONT face="宋體">  
<P>  
<ASP:Label id="lblWeather" runat="server">Weather</ASP:Label></P>  
<P>  
<ASP:Button id="btnGet" runat="server" Text="Get Weather"> 
</ASP:Button></P>  
<P>  
<ASP:Label id="Weather2" runat="server">24小時(shí)天氣</ASP:Label></P>  
<P>  
<ASP:Button id="btnGet2" runat="server" Text="天氣預(yù)報(bào)"> 
</ASP:Button></P>  
</FONT>  
</form>  
</body>  
</HTML>
getWeather.ASPx.cs 
--------------------------------------- 

復(fù)制代碼 代碼如下:using System;  
using System.Collections;  
using System.ComponentModel;  
using System.Data;  
using System.Drawing;  
using System.Web;  
using System.Web.SessionState;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using System.Web.UI.HtmlControls;  
using System.NET;  
using System.IO;  

namespace test  
{  

public class GetWeather : System.Web.UI.Page  
{  
protected System.Web.UI.WebControls.Label lblWeather;  
protected System.Web.UI.WebControls.Label Weather2;  
protected System.Web.UI.WebControls.Button btnGet2;  
protected System.Web.UI.WebControls.Button btnGet;  

private void Page_Load(object sender, System.EventArgs e)  
{  
// Put user code to initialize the page here  
}  

#region Web Form Designer generated code  
override protected void OnInit(EventArgs e)  
{  
//  
// CODEGEN: This call is required by the ASP.NET Web Form Designer.  
//  
InitializeComponent();  
base.OnInit(e);  
}  

/// <summary>  
/// Required method for Designer support - do not modify  
/// the contents of this method with the code editor.  
/// </summary>  
private void InitializeComponent()  
{  
this.btnGet.Click += new System.EventHandler(this.btnGet_Click);  
this.btnGet2.Click += new System.EventHandler(this.btnGet2_Click);  
this.Load += new System.EventHandler(this.Page_Load);  

}  
#endregion  

private void btnGet_Click(object sender, System.EventArgs e)  
{  

WebRequest wreq=WebRequest.Create 
("http://weather.yahoo.com/forecast/CHXX0037_c.html");  

HttpWebResponse wresp=(HttpWebResponse)wreq.GetResponse();  

string HTML ="";  
Stream s=wresp.GetResponseStream();  

StreamReader objReader = new StreamReader(s);  

string sLine = "";  
int i = 0;  

while (sLine!=null)  
{  
i++;  
sLine = objReader.ReadLine();  
if (sLine!=null)  
HTML += sLine;  
}  

String temp= "";  
int start,stop;  

start = HTML.IndexOf("<!-- CURCON-->",0,HTML.Length);  

stop = HTML.IndexOf("<!-- END CURCON-->",0,HTML.Length);  

temp = HTML.Substring(start, stop - start);  
start = temp.IndexOf("<b>");  
stop = temp.IndexOf("</b>");  

string degree = temp.Substring(start+3,stop - start -3);  

start = temp.IndexOf("<img");  
stop = temp.IndexOf("</td>",start);  

string img = temp.Substring(start,stop - start);  
lblWeather.Text = degree + "<br>" + img;  

}  

private void btnGet2_Click(object sender, System.EventArgs e)  
{  
WebRequest wreq=WebRequest.Create 
("http://cn.weather.yahoo.com/CHXX/CHXX0037/index_c.html");  

HttpWebResponse wresp=(HttpWebResponse)wreq.GetResponse();  

string HTML ="";  
Stream s=wresp.GetResponseStream();  

StreamReader objReader = new StreamReader(s,System.Text.Encoding.GetEncoding("GB2312"));  


string sLine = "";  
int i = 0;  

while (sLine!=null)  
{  
i++;  
sLine = objReader.ReadLine();  
if (sLine!=null)  
HTML += sLine;  
}  

String temp= "";  
int start,stop;  

start = HTML.IndexOf("<table border=0 cellpadding=2  
cellspacing=1 bgcolor=9999cc width=/"85%/">",0,HTML.Length);  

stop = HTML.IndexOf("</table>",start)+8;  


temp = HTML.Substring(start, stop - start);  
Weather2.Text = temp;  
}  
}  
}  請(qǐng)注明轉(zhuǎn)自chinazhan中國(guó)站長(zhǎng)

AspNet技術(shù)ASP.net(c#)打造24小時(shí)天氣預(yù)報(bào)及實(shí)時(shí)天氣,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 以下关于宏病毒说法正确的是 | 秀人网美女屋| 十个世界尽头| 漂亮孕妇肚子疼视频要生了| 梁祝《引子》简谱| 宇宙魔方| 悦来换电| 口舌 — 视频 | vk| 南营洞| 帮妈妈做饭看图写话二年级| 戒色视频| 牛奶奶油是什么奶油| 泰国xxx| 引诱| 老炮儿演员表| 贵州三日游| 电影 本能| 女人 电影| 爆操女人逼| 恶搞之家拍脏片八季是哪一集| 三浦亚沙妃| 吸痰护理ppt课件| 大兵相声小品蠢得死| 王瑞儿视频| ctv5| 间宫夕贵电影| 全国城建培训中心| cctv体育频道5| 春江花月夜理解性默写及答案| 日韩欧美视频在线播放| 咖啡王子一号店| 正在行动| 孔冉| 人世间豆瓣| 爱的重生| 他其实没那么爱你电影| 抖音1| 电视剧暗夜与黎明剧情介绍| 那根所有权| 郭亚菲| 挠胳肢窝肚子腰|