Search code examples
pythonproxypython-requestsuser-agent

Python Proxy Requests and User Agent


I was playing around with a proxy requests module that I found here/pip install proxy-requests. I have successfully been making GET/POST requests to a temporary ptsv2.com bucket as shown in the directions and it seems to be working... My IP listed is actually a proxy server's IP. However my User Agent (in the header) still says Python Requests with a version number. Is it possible to use this module's proxy IP capabilities but also change the User Agent to something other than Python Requests? I want to hide my IP but also the user-agent as well.


Solution

  • You can set User-Agent in headers like so:

    headers = {
        'User-Agent': 'Some custom user agent',
    }
    
    r = ProxyRequests("url here")
    r.set_headers(headers)
    r.post_with_headers({"key1": "value1", "key2": "value2"})