Create StreamReader from URL
Imports System.Net
Imports System.IO
Module Test
Sub Main()
Dim sURL As String
sURL = "http://msdn.microsoft.ru"
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
<?xml version="1.0" encoding="UTF-8" ?>
<!-- MTPS 0606 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtm
l1-transitional.dtd">
<html id="ctl00_Html1" xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-us">
<head id="ctl00_Head1"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="ms.locale" content="en-us" />
Read from a URL
Imports System
Imports System.Net
Imports System.IO
Imports System.Environment
Module GetURL
Sub Main()
Dim sOutput As String
Dim sURL As String = "http://www.vbex.ru"
Try
Dim objNewRequest As WebRequest = HttpWebRequest.Create(sURL)
Dim objResponse As WebResponse = objNewRequest.GetResponse
Dim objStream As New StreamReader(objResponse.GetResponseStream())
sOutput = objStream.ReadToEnd()
Catch eUFE As UriFormatException
sOutput = "Error in URL Format: [" & sURL & "]" & NewLine() & eUFE.Message
Catch eWEB As WebException
sOutput = "Error With Web Request: " & NewLine() & eWEB.Message
Catch e As Exception
sOutput = e.ToString
Finally
Console.Write(sOutput)
End Try
End Sub
End Module
<HTML>
<HEAD>
Java examples (example source code) Organized by topic </title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta http-equiv="content
-style-type" content="text/css"/>
<meta name="author" content="Demo Source and Support Ltd."/>
<meta name="copyright" content="2006 Demo Source and Support Ltd."/>
<meta name="description" CONTENT=" Java examples (example source code) Organized by topic " />
<meta name="keywords" CONTENT=" Java examples (example source code) Organized by topic "/>
<SCRIPT language=javascript1.2>