【问题标题】:How can I verify that requests.get() used the proxy and not my ip in python3?如何验证 requests.get() 在 python3 中使用了代理而不是我的 ip?
【发布时间】:2018-09-16 22:39:50
【问题描述】:

我发出一个 GET 请求: requests.get(url, proxies={'https':'x.x.x.x:xxxx'})

如何验证请求是通过代理而不是从我的 IP 发出的?

【问题讨论】:

    标签: python-3.x proxy get ip python-requests


    【解决方案1】:

    我不确定它是否会显示您要查找的内容,但您也许可以启用日志记录并查看代理

    logging.basicConfig() # you need to initialize logging, otherwise you will not see anything from requests
    logging.getLogger().setLevel(logging.DEBUG)
    requests_log = logging.getLogger("urllib3")
    requests_log.setLevel(logging.DEBUG)
    requests_log.propagate = True
    

    参考:http://docs.python-requests.org/en/master/api/
    在代理使用上方的pa底部

    【讨论】:

    • 感谢您的回复。但是,我没有看到我想在日志消息中看到的内容。我有兴趣证明服务器收到了来自代理而不是我的请求。
    猜你喜欢
    • 1970-01-01
    • 2011-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-22
    • 1970-01-01
    • 2013-09-27
    相关资源
    最近更新 更多