VB.Net Tutorial/Socket Network/WebRequest — различия между версиями

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

Версия 16:40, 26 мая 2010

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"/>