而需傳入日期參數 ex. date=2009-05-13T17:01:06
而檔案每過一會就會更新,如何取得最新的檔案呢??
我們可透過截取html碼 再去分割出所要的部份去完成
完整程式碼如下
Partial Class _Default
Inherits System.Web.UI.Page
Dim strTemp, str As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim url As String = "http://rate.bot.com.tw/Pages/Static/UIP003.zh-TW.htm"
Dim request As Net.WebRequest = Net.WebRequest.Create(url)
Dim response5 As Net.WebResponse
response5 = request.GetResponse()
'宣告WebRequest物件
Dim myRequest5 As System.Net.WebRequest = System.Net.WebRequest.Create(url)
'取得網頁資訊流
Dim myResponse5 As System.Net.WebResponse = myRequest5.GetResponse()
'宣告StreamReader讀取資料
Dim sr5 As System.IO.StreamReader = New System.IO.StreamReader(myResponse5.GetResponseStream(), System.Text.Encoding.Default)
'資料讀取到字串變數中
Dim content5 As String = sr5.ReadToEnd()
'關閉StreamReader
sr5.Close()
'關閉連線
myResponse5.Close()
strTemp = Split(content5, "下載 Excel 檔")(0)
strTemp = Split(strTemp, "/Pages/")(UBound(Split(strTemp, "/Pages/")))
str = str & strTemp
str = str.ToString.Substring(0, str.Length - 10)
str = "http://rate.bot.com.tw/Pages/" & str
End Sub
End Class
因為有網友反應,故在此附上此程式原始檔~並己編譯成exe
請按這裡下載
1 則留言:
高手,謝謝您無私的提供。
Patrick
張貼留言