代码语言:javascript复制
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER,r"SoftwareMicrosoftWindowsCurrentVersionInternet Settings",access=winreg.KEY_ALL_ACCESS)
winreg.SetValueEx(key,"ProxyEnable", 0,winreg.REG_DWORD,1)
winreg.SetValueEx(key, "ProxyServer", 0,winreg.REG_SZ,"127.0.0.1:8080")
a=os.path.dirname(sys.argv[0])
b=os.path.join(a,"ips.txt")
with open(b) as ips:
iplist=ips.readlines()
ipstring=';'.join(iplist)
winreg.SetValueEx(key, "ProxyOverride", 0,winreg.REG_SZ,ipstring)
ips.txt保存不经过代理的域名
关闭代理
代码语言:javascript复制donekey = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
r"SoftwareMicrosoftWindowsCurrentVersionInternet Settings",
access=winreg.KEY_ALL_ACCESS)
winreg.SetValueEx(donekey, "ProxyEnable", 0, winreg.REG_DWORD, 0)