【问题标题】:Python Requests Proxy ErrorPython 请求代理错误
【发布时间】:2018-01-08 07:24:30
【问题描述】:

所以当我尝试在 python 请求上使用代理时,实际发送的请求是使用我自己的 ip

http_proxy = "https://103.235.21.128:80" 代理字典 = { “http”:http_proxy, } r = requests.get('http://whatismyip.org',proxies=proxyDict) 打印 r.content

也试过了

http_proxy = "https://103.235.21.128:80" 代理字典 = { “https”:http_proxy, } r = requests.get('http://whatismyip.org',proxies=proxyDict) 打印 r.content

那么为什么请求使用我的真实 ip 而不是我提供的代理

【问题讨论】:

  • 您的代理不太可能将端口 80 用于 https,这可能是导致代理无法为您工作的原因。您应该检查您代理处理每个协议(http、https、ftp 等)的端口

标签: python proxy


【解决方案1】:

你试过这样在代理上设置http吗?

http_proxy  = "http://103.235.21.128:80"

http_proxy = "http://{}:{}".format('103.235.21.128', 80)

如果这不起作用,您可能需要找到一个 http 代理

如果您从多个网站(http 和 https)请求数据,则必须将两者都添加到字典中:

proxyDict = {"http": http_proxy, "https": http_proxy}

【讨论】:

    猜你喜欢
    • 2012-02-10
    • 2016-10-19
    • 2018-08-05
    • 1970-01-01
    • 2022-07-05
    • 1970-01-01
    • 1970-01-01
    • 2016-12-24
    • 1970-01-01
    相关资源
    最近更新 更多