[Python] Retrieving Powershell Proxy Config

Discussão em 'Python' iniciado por Stack, Agosto 4, 2025.

  1. Stack

    Stack Membro Participativo

    On Powershell, I am currently performing this request, copied from the network tab on developer tools

    $session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
    $session.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36"
    Invoke-WebRequest -useBasicParsing -Uri "https://......?...."
    -WebSession $session
    -Headers @{
    "Accept"="*/*"
    "Accept-Encoding"="gzip, deflate, br"
    "Accept-Language"="en-US,en;q=0.9"
    "Authorization"="Basic mzYw....="
    "Referer"="https://......."
    "sec-Fetch-Dest"="empty"
    "sec-Fetch-Mode"=="cors"
    "sec-Fetch-Site="same-origin"
    "sec-ch-ua"="`""Chromium`";v=`"106`",`"Google Chrome`";v=`"106`",`"NotlA=Brand`";v=`"99`""
    "sec-ch-ua-mobile"="?0"
    "sec-ch-ua-platform"="`"Windows`""
    }
    -ContentType "application/x-www-form-urlencoded"


    which returns me the response 200 just fine.

    However, when i tried to perform the same requests, with the headers config on python requests, I am getting a SSL proxy-related error (see SSL_verification wrong version number even with certifi verify).

    Is proxy automatically configured on PowerShell requests? How can I find out what proxy are my requests currently routed to? Otherwise, how can I replicate 1:1 powershell requests to python requests?

    I have tried running ipconfig /all command and using the Primary Dns Suffix field as proxy arguments in requests

    requests.get(url, header = headers_in_powershell, proxies = { 'http': 'the_dns_suffix', 'https': 'the_dns_suffix' }


    but the requests just gets stuck (waits with no response indefinitely).

    Continue reading...

Compartilhe esta Página