輸入city name搜尋,如kaohsiung,會link至
http://weather.msn.com/local.aspx?wealocations=wc:16133
然後後上角有個rss圖示,會link至
http://weather.msn.com/RSS.aspx?wealocations=wc:16133&weadegreetype=C
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Me.Label1.Text = readRSS()
Me.Label2.Text = Now.ToString("yyyy/MM/dd-hh:mm")
End If
End Sub
Function readRSS()
Dim myDataset As New Data.DataSet
myDataset.ReadXml(Me.DropDownList1.SelectedValue)
Dim tempString As String
tempString = myDataset.Tables(3).Rows(1).Item("description")
Dim myDay1, myDay2, myDay3 As String
tempString = tempString.Replace("<p>", "")
tempString = tempString.Replace("</p>", "")
myDay1 = tempString.Substring(0, tempString.IndexOf("<br />"))
tempString = tempString.Remove(0, tempString.IndexOf("<br />") + 6)
myDay2 = tempString.Substring(0, tempString.IndexOf("<br />"))
tempString = tempString.Remove(0, tempString.IndexOf("<br />") + 6)
myDay3 = tempString.Substring(0, tempString.IndexOf("<br />"))
Dim sb As New StringBuilder
sb.Append("今天:" & myWeather(myDay1) & "<BR>")
sb.Append("明天:" & myWeather(myDay2) & "<BR>")
sb.Append("後天:" & myWeather(myDay3))
Return sb.ToString()
End Function
Function myWeather(ByVal tempString As String)
Dim Weather As String
Dim myString As String
myString = tempString
myString = myString.Remove(0, myString.IndexOf("<img"))
myString = myString.Substring(0, myString.IndexOf(">") + 1)
Weather = myString
myString = tempString
myString = myString.Remove(0, myString.IndexOf("Lo:"))
myString = myString.Substring(0, myString.IndexOf("."))
myString = myString.Replace("Lo:", " ")
Weather = Weather & myString
myString = tempString
myString = myString.Remove(0, myString.IndexOf("Hi:"))
myString = myString.Substring(0, myString.IndexOf("."))
myString = myString.Replace("Hi:", " ")
Weather = Weather & " ~ " & myString
Return Weather
End Function
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
Me.Label1.Text = readRSS()
Me.Label2.Text = Now.ToString("yyyy/MM/dd-hh:mm")
End Sub
Protected Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Label1.Text = readRSS()
Me.Label2.Text = Now.ToString("yyyy/MM/dd-hh:mm")
End Sub
End Class
留言列表