[Python] Python Requests Returns Encoded Data

Discussão em 'Python' iniciado por Stack, Fevereiro 24, 2025.

  1. Stack

    Stack Membro Participativo

    I have an API that is running on my server that I access using the requests module. The code that was working was:

    import requests
    response = requests.post("https://example.com/api/v1/endpoint")
    print(response.json())


    which would return:


    {"status":200,"message":"Successfully refreshed"}
    ​

    Recently I restarted the server. I did not make any changes to my code but now the response is


    (\xb5/\xfd\x04Xd\x14\x00F\xa6r0\x90'i\x03\xff\xff\xff\x7f}\xf9!\xb6Ek\xb4v\x98....
    ​

    If I import a different module from curl_cffi import requests, I get the normal response. Why is requests module returning the encoded string now?

    Edit: This seems to be an issue with other URLs too when accessed from this server, not just my own domain.

    Continue reading...

Compartilhe esta Página