【发布时间】:2017-02-15 17:01:48
【问题描述】:
如何在 MacOS 中使用 python 更改 Internet 代理设置以设置 Proxy server 和 Proxy port
我使用以下代码在 Windows 上执行此操作:
import _winreg as winreg
INTERNET_SETTINGS = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r'Software\Microsoft\Windows\CurrentVersion\Internet Settings', 0, winreg.KEY_ALL_ACCESS)
def set_key(name, value):
_, reg_type = winreg.QueryValueEx(INTERNET_SETTINGS, name)
winreg.SetValueEx(INTERNET_SETTINGS, name, 0, reg_type, value)
set_key('ProxyEnable', 0)
set_key('ProxyOverride', u'*.local;<local>') # Bypass the proxy for localhost
set_key('ProxyServer', u'proxy.example.com:8080')
这可以在 MacOS 上实现吗?
【问题讨论】:
标签: python macos python-2.7 python-3.x proxy