如何在Windows 8中使用python更改代理设置?

时间:2013-02-24 07:39:04

标签: python windows-8 internet-explorer-10

如何在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

0 个答案:

没有答案