Created
January 24, 2025 00:11
-
-
Save pedroinfo/4490cb19e58672f88d95cf64e2ffbcbf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub RequisicaoHTTPUsandoProxyAutomatico() | |
Dim HTTP As Object | |
Dim URL As String | |
Dim Resultado As String | |
' URL para teste | |
URL = "http://www.google.com" | |
' Criação do objeto ServerXMLHTTP | |
Set HTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0") | |
On Error Resume Next | |
' Configura para usar o proxy padrão do sistema (modo automático) | |
HTTP.SetProxy 1 ' 1 = Usar proxy do sistema configurado automaticamente | |
' Fazendo a solicitação | |
HTTP.Open "GET", URL, False | |
HTTP.Send | |
' Verifica o status da resposta | |
If HTTP.Status = 200 Then | |
Resultado = "Requisição bem-sucedida! Resposta recebida: " & vbCrLf & HTTP.ResponseText | |
Else | |
Resultado = "Falha na requisição. Status HTTP: " & HTTP.Status | |
End If | |
On Error GoTo 0 | |
' Exibe o resultado | |
MsgBox Resultado, vbInformation, "Resultado da Requisição" | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment