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', '*.local;<local>')
set_key('ProxyServer', 'X.X.X.X:8080')
Change browser proxy settings from Python?