Windows8でpythonを使用してプロキシ設定を設定するにはどうすればよいですか? このコードを試しましたが、機能しません..設定が変更されません
def inst_proxy5(self):
""" sets institute proxy"""
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', 1)
set_key('ProxyOverride', u'*.local;<local>') # Bypass the proxy for localhost
set_key('ProxyServer', u'192.168.0.5:3128')
root.destroy()`
これをコメントすると、うまくいきます..これを設定する方法も
set_key('ProxyOverride', u'*.local;<local>') # Bypass the proxy for localhost
このエラーが発生します:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__
return self.func(*args)
File "C:\py_pro\but1.py", line 82, in inst_proxy22
set_key('ProxyOverride', u'*.local;<local>') # Bypass the proxy for localhost
File "C:\py_pro\but1.py", line 79, in set_key
_, reg_type = winreg.QueryValueEx(INTERNET_SETTINGS, name)
WindowsError: [Error 2] The system cannot find the file specified