Python 代理请求和用户代理

Python Proxy Requests and User Agent

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

您可以像这样在 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"})