【问题标题】:Proxy server doesn't change public IP with Python Requests代理服务器不会使用 Python 请求更改公共 IP
【发布时间】:2020-07-19 12:07:38
【问题描述】:

我正在运行这个脚本:

import requests

proxyDict = {"http"  : 'http://81.93.73.28:8081'}

r = requests.get('http://ipinfo.io/ip', proxies=proxyDict)
r.status_code
r.headers['content-type']

r.encoding

print(r.text)

我已经尝试过我自己的代理服务器以及几个公共服务器。它仍然打印我当前的 ip。 我做错了什么?

【问题讨论】:

  • 这能回答你的问题吗? Proxies with Python 'Requests' module
  • 不,我的脚本是基于这些答案。由于某种原因不起作用。可能只是一个新手的错误,我几乎不知道python
  • @sktvlfw 你能接受我的回答吗?

标签: python proxy python-requests


【解决方案1】:

问题似乎与代理有关。我用那个代码尝试了随机的、免费的。此外,您的代码有一些问题。您在没有使用的情况下调用属性 - 它们没有必要。尝试使用该代码和代理,对我来说,它有效。

proxyDict = {"http"  : 'http://162.14.18.11:80'}

r = requests.get('http://ipinfo.io/ip', proxies=proxyDict, )
print(r.status_code)

print(r.text)

【讨论】:

    猜你喜欢
    • 2017-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-31
    • 1970-01-01
    • 2017-02-11
    • 2012-05-09
    • 1970-01-01
    相关资源
    最近更新 更多