V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
61882328
V2EX  ›  Python

使用 from selenium import webdriver.Chrom() 每次都会弹出浏览器窗口,有办法关闭吗

  •  
  •   61882328 · Apr 21, 2017 · 9196 views
    This topic created in 3307 days ago, the information mentioned may be changed or developed.

    close 和 quit 都只能在 get 完才能使用

    有什么方法可以隐藏 chrome 的窗口呢?

    
    from selenium import webdriver
    
    driver = webdriver.Chrome()
    
    driver.get('http://www.domain.com/play/145804.html')
    
    for i in driver.find_elements_by_id('jp_audio_0'):
    
        print("Value is: %s" % i.get_attribute("src"))
        
    driver.close()
    
    driver.quit()
    
    6 replies    2017-04-22 00:06:17 +08:00
    guokeke
        2
    guokeke  
       Apr 21, 2017
    61882328
        3
    61882328  
    OP
       Apr 21, 2017
    谢谢。。我试下。
    yezhiye
        4
    yezhiye  
       Apr 21, 2017
    不尝试下无头浏览器吗……
    wangxiaodong
        5
    wangxiaodong  
       Apr 21, 2017
    mingyun
        6
    mingyun  
       Apr 22, 2017
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3738 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 10:39 · PVG 18:39 · LAX 03:39 · JFK 06:39
    ♥ Do have faith in what you're doing.