VB.Net Tutorial/Socket Network/WebRequest

Материал из VB Эксперт
Перейти к: навигация, поиск

Read a web page with WebRequest

Imports System.Net
Imports System.IO
Imports System.Text

Public Class Tester
    Public Shared Sub Main

        Try
            Dim myWebRequest As WebRequest = WebRequest.Create("http://www.vbex.ru")
            Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
            Dim myStream As Stream = myWebResponse.GetResponseStream()
            Dim mybyte(1024) As Byte
            Dim intreadl As Integer = 0
            Do
                intreadl = myStream.Read(mybyte, 0, 1024)
                Console.WriteLine(Encoding.UTF8.GetString(mybyte, 0, 1024))
            Loop While intreadl > 0
            myStream.Close()
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
    End Sub
End Class
<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"/>