微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

您正在连接的代理不在 GetAuthCredentials 回调函数中的列表错误中

如何解决您正在连接的代理不在 GetAuthCredentials 回调函数中的列表错误中

我在 Chromium 实例上出现白屏,同时尝试使用回调函数来验证我的代理。这是我的代码

def main():
check_versions()
sys.excepthook = cef.ExceptHook  # To shutdown all CEF processes on error
applicationSettings = {
    "unique_request_context_per_browser": 1,"ignore_certificate_errors": 1,"persist_session_cookies": 1,"persist_user_preferences": 1,"string_encoding": "utf-8","user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/91.0.4472.106 Safari/537.36","context_menu": {
        "enabled": True,"navigation": True,"print": True,"view_source": True,"external_browser": True,"devtools": True,}

}
commandLineswitches = {
    "proxy-server": "host:port","force-webrtc-ip-handling-policy": "default_public_interface_only",}
cef.Initialize(applicationSettings,commandLineswitches)
browser = cef.CreatebrowserSync(url="https://www.google.com/",window_title="Hello World!")
browser.SetClientHandler(RequestHandler("username","password"))
cef.MessageLoop()
del browser
cef.Shutdown()


class RequestHandler(object):
    def __init__(self,username,password):
        self.username = username
        self.password = password

    def GetAuthCredentials(self,browser,is_proxy,**_):
        if is_proxy:
            resp = _['callback'].Continue(self.username,self.password)
            print(_)
            print(resp)
            return True
        return False


def check_versions():
    ver = cef.GetVersion()
    print("[hello_world.py] CEF Python {ver}".format(ver=ver["version"]))
    print("[hello_world.py] Chromium {ver}".format(ver=ver["chrome_version"]))
    print("[hello_world.py] CEF {ver}".format(ver=ver["cef_version"]))
    print("[hello_world.py] Python {ver} {arch}".format(
       ver=platform.python_version(),arch=platform.architecture()[0]))
assert cef.__version__ >= "57.0","CEF Python v57.0+ required to run this"


if __name__ == '__main__':
    main()

这就是我在命令行中得到的(无限循环):

{'frame': <cefpython_py39.PyFrame object at 0x0000023E38F0B380>,'host': 'host','port': port,'realm': 'Invalid proxy credentials or missing IP Authorization.','scheme': 'basic','callback': <cefpython_py39.PyAuthCallback object at 0x0000023E36A87E30>}
None
{'frame': <cefpython_py39.PyFrame object at 0x0000023E38F0B3C0>,'realm': 'The proxy you are connecting is not in your list.','callback': <cefpython_py39.PyAuthCallback object at 0x0000023E36A87E30>}
None

找不到任何可行的解决方案。也许我遗漏了一些明显的东西,提前感谢您的帮助!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。