推荐学习书目
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 · Feb 28, 2019 · 4705 views
    This topic created in 2660 days ago, the information mentioned may be changed or developed.

    QQ 截图 20190228103914.png

    试过 driver.switch_to.alert, 无效

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

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

    不过这样就不能无头浏览了
    arrow8899
        10
    arrow8899  
       Feb 28, 2019
    windows 新建一个 .reg 注册表文件,之后双击导入

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\AutoSelectCertificateForUrls]
    "1"="{\"pattern\":\"https://[*.].example.com\",\"filter\":{\"ISSUER\":{\"CN\":\"你的证书名称\"}}}"
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1317 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 23:47 · PVG 07:47 · LAX 16:47 · JFK 19:47
    ♥ Do have faith in what you're doing.