【问题标题】:"requests-html" proxy setting not working“requests-html”代理设置不起作用
【发布时间】:2021-06-03 08:44:09
【问题描述】:

我正在使用以下代码为HTMLSessionget() 方法设置代理。不过,它使用我的 IP 而不是代理 IP。

代理字符串格式:

http://username:password@ip:port

r = session.get('https://whatismyipaddress.com/', proxies={'http': proxy})
r.html.find('p.ip-address')[0].text

在上面打印以下是我当前的 IP 地址。

'IPv4:? The most common IP version is assigned by ISPs. 175.157.?.?'

【问题讨论】:

    标签: python-requests-html


    【解决方案1】:

    您需要在代理中添加“https”:

    proxy = 'http://username:password@ip:port'
    r = session.get('https://whatismyipaddress.com/', proxies={'http': proxy, 'https': proxy})
    

    【讨论】:

      猜你喜欢
      • 2011-07-19
      • 2018-11-27
      • 2023-01-16
      • 1970-01-01
      • 2019-01-19
      • 1970-01-01
      • 1970-01-01
      • 2013-10-23
      • 1970-01-01
      相关资源
      最近更新 更多