2009年11月2日 星期一

從URL讀取網頁

Imports System.Net
Imports System.IO

Module Test

Sub Main()
Dim sURL As String
sURL = "http://msdn.microsoft.com%22
Try
Dim objNewRequest As WebRequest = HttpWebRequest.Create(sURL)
Dim objResponse As WebResponse = objNewRequest.GetResponse
Dim objStream As New StreamReader(objResponse.GetResponseStream())
Console.WriteLine(objStream.ReadToEnd())
Catch eUFE As UriFormatException
Console.WriteLine(eUFE.Message)
Catch eWEB As WebException
Console.WriteLine(eWEB.Message)
Catch e As Exception
Console.WriteLine(e.ToString)
End Try
End Sub
End Module

轉自: http://www.java2s.com

沒有留言: