Visual Basic

This article provides an example of using a proxy to make an HTTP request with the Visual Basic programming language.

Visual Basic Code

In this example, we use the Residential proxy below:

residential.pingproxies.com:7777:customer-tt_pp_lz_5051-sessid-Z9tCGVYHu:23n22mk22

This proxy is split into four parts separated by colons. We first save the proxy as a string variable, then split it into four parts at each colon (:) and then add it, with authentication, to our proxy dictionary.

Imports System.IO
Imports System.Net
Module Module1
    Private Const proxy_string = "residential.pingproxies.com:7777:customer-tt_pp_lz_5051-sessid-Z9tCGVYHu:23n22mk22"
    Private proxy_parts As String() = proxy_string.Split(":"c)
    Private ip_address As String = proxy_parts(0)
    Private port As String = proxy_parts(1)
    Private username As String = proxy_parts(2)
    Private password As String = proxy_parts(3)
    Private Const url As String = "http://www.google.com/"
    Sub Main()
        Dim httpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
        Dim webProxy = New WebProxy(New Uri("http://" & ip_address & ":" & port)) With {
                .Credentials = New NetworkCredential(username, password)
                }
        httpWebRequest.Proxy = webProxy
        Dim httpWebResponse = CType(httpWebRequest.GetResponse(), HttpWebResponse)
        Console.WriteLine($"Response:{httpWebResponse.StatusCode}")
        Console.ReadKey()
    End Sub
End Module

Last updated