Visual Basic

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:


resi.ipv6.plainproxies.com:8080:customer:product--resi6--pass--nicepass


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 = "resi.ipv6.plainproxies.com:8080:customer:product--resi6--pass--nicepass"  
    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

Updated on: 20/02/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!