olivebot/test/clear_proxy.py
xszyou 57b362fa6b 提高抖音字幕监听的稳定性及包兼容性
1、清除旧逻辑代码;
2、优化监听逻辑;
3、调整包版本的兼容性python3.8、3.9、3.10。
2023-04-24 12:46:17 +08:00

27 lines
833 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import winreg
#关闭系统代理
def disable_windows_proxy():
settings_key = r'Software\Microsoft\Windows\CurrentVersion\Internet Settings'
try:
registry = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
settings = winreg.OpenKey(registry, settings_key, 0, winreg.KEY_WRITE)
# 设置代理启用值为0禁用
winreg.SetValueEx(settings, 'ProxyEnable', 0, winreg.REG_DWORD, 0)
# 清空代理服务器和代理覆盖设置
winreg.SetValueEx(settings, 'ProxyServer', 0, winreg.REG_SZ, '')
winreg.SetValueEx(settings, 'ProxyOverride', 0, winreg.REG_SZ, '')
winreg.CloseKey(settings)
winreg.CloseKey(registry)
except Exception as e:
pass
if __name__ == '__main__':
disable_windows_proxy()