V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
KevinBu
V2EX  ›  Python

Python +Selenium 如何操作选择证书的对话框?

  •  
  •   KevinBu · 2019-02-28 10:44:36 +08:00 · 3925 次点击
    这是一个创建于 1855 天前的主题,其中的信息可能已经有所发展或是发生改变。

    QQ 截图 20190228103914.png

    试过 driver.switch_to.alert, 无效

    10 条回复    2019-02-28 17:09:26 +08:00
    izoabr
        1
    izoabr  
       2019-02-28 10:48:31 +08:00
    这是双向证书验证吧?
    ctro15547
        2
    ctro15547  
       2019-02-28 11:02:33 +08:00
    配合按键精灵之类的东西吧
    congeec
        3
    congeec  
       2019-02-28 11:07:46 +08:00   ❤️ 2
    selenium 做不到,因为这玩意儿不在 dom 里
    用 windows api 找到窗口按钮,点一下就好
    #2 说的方法也不错
    pupie
        4
    pupie  
       2019-02-28 12:00:38 +08:00   ❤️ 1
    autoit 脚本生成 exe 操作 windows 窗口,python 中调用这个程序
    KevinBu
        5
    KevinBu  
    OP
       2019-02-28 13:38:38 +08:00
    @congeec
    @pupie

    这样子就不能 无头浏览了吧
    alvin666
        7
    alvin666  
       2019-02-28 16:31:40 +08:00 via Android
    或者 selenium 登陆后拿到 cookie,抓包,用 requests 来做?
    KevinBu
        8
    KevinBu  
    OP
       2019-02-28 16:57:39 +08:00
    @alvin666 我试过了,不行的,cookie 是没错,但是要验证证书
    KevinBu
        9
    KevinBu  
    OP
       2019-02-28 16:59:33 +08:00
    @whwlsfb 这个我能用 Python 实现,模拟鼠标键盘操作

    不过这样就不能无头浏览了
    arrow8899
        10
    arrow8899  
       2019-02-28 17:09:26 +08:00
    windows 新建一个 .reg 注册表文件,之后双击导入

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\AutoSelectCertificateForUrls]
    "1"="{\"pattern\":\"https://[*.].example.com\",\"filter\":{\"ISSUER\":{\"CN\":\"你的证书名称\"}}}"
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3260 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 12:03 · PVG 20:03 · LAX 05:03 · JFK 08:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.