How to read a URL Content

In VB.NET, when the requirement arises to access and retrieve the content of an HTML page from a remote web server, the commonly employed approach involves utilizing the WebRequest and WebResponse classes. By employing these classes, developers can establish a connection with the remote web server, retrieve the desired content, and effectively manage the response.

Upon sending a request to the remote web server using WebRequest, the corresponding WebResponse object is generated, providing access to the server's response. To extract the content from the received response, developers can utilize the StreamReader class, which allows for efficient and seamless retrieval of textual data.


By employing the StreamReader associated with the WebResponse, developers can effortlessly access and process the content of the HTML page. This enables the extraction of pertinent information, such as text, tags, or specific data points, from the remote web server's response.

Full Source VB.NET
Imports System.Net Imports System.IO Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim inStream As StreamReader Dim webRequest As WebRequest Dim webresponse As WebResponse webRequest = webRequest.Create(TextBox1.Text) webresponse = webRequest.GetResponse() inStream = New StreamReader(webresponse.GetResponseStream()) TextBox2.Text = inStream.ReadToEnd() End Sub End Class


The combination of WebRequest, WebResponse, and StreamReader classes in VB.NET facilitates the seamless retrieval and processing of HTML content from remote web servers. This enables developers to extract valuable data and incorporate it into their applications, enhancing functionality, data analysis, or information display.