【问题标题】:Python Proxy Requests and User AgentPython 代理请求和用户代理
【发布时间】:2026-02-12 03:05:01
【问题描述】:

我正在玩我发现here/pip install proxy-requests 的代理请求模块。我已经成功地向临时 ptsv2.com 存储桶发出 GET/POST 请求,如说明所示,它似乎正在工作......我列出的 IP 实际上是代理服务器的 IP。但是,我的用户代理(在标题中)仍然显示带有版本号的 Python 请求。是否可以使用此模块的代理 IP 功能,但也可以将用户代理更改为 Python 请求以外的其他内容?我想隐藏我的 IP,也想隐藏用户代理。

【问题讨论】:

    标签: python proxy python-requests user-agent


    【解决方案1】:

    您可以像这样在headers 中设置User-Agent

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

    【讨论】:

    • 嗯,是的。我不确定我是否应该使用假用户代理模块,但我什至不需要。非常感谢!