Download website source code with VB.net

This is a simple guide about how to download a websites source code with Visual Basic.

Imports System.Net
Public Class Form1
    Private Sub SearchButton_Click(sender As Object, e As EventArgs) Handles SearchButton.Click

        Dim client As WebClient = New WebClient()
        client.Headers("User-Agent") = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0"
        TextBox1.Text = client.DownloadString("http://example.com/")

    End Sub
End Class

This piece of code will put the source code from example.com in a textbox called TextBox1.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.