代码之家  ›  专栏  ›  技术社区  ›  Esteban Küber

如何在使用python的Windows中设置代理?

  •  1
  • Esteban Küber  · 技术社区  · 15 年前

    如何获取当前Windows的浏览器代理设置,并将其设置为值?

    我知道我可以通过在登记处 Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer 但是,如果可能的话,我想在不直接影响注册的情况下做到这一点。

    3 回复  |  直到 13 年前
        1
  •  3
  •   Diaa Sami    15 年前

    当没有代理被指定为参数或环境变量时,urllib模块会自动从注册表中检索设置。

    在Windows环境中,如果没有代理 设置环境变量,代理 设置从 注册表的Internet设置部分。

    请参阅前面文章中引用的URLLIB模块文档。

    要设置代理,我假设您需要使用pywin32模块并直接修改注册表。

        2
  •  0
  •   jkp    15 年前

    如果您使用的代码使用 urlopen 在引擎盖下你一套 http_proxy 环境变量来获取它。

    documentation 这里有更多的信息。

        3
  •  0
  •   Community CDub    7 年前

    可以使用winhttpgetieproxyconfigforcurrentuser,如中所述。 this SO question

    another SO question 例如 PyWin32 ,用于Windows扩展的python。