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
61882328
V2EX  ›  Python

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

  •  
  •   61882328 · 2017-04-21 17:05:43 +08:00 · 8296 次点击
    这是一个创建于 2566 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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 条回复    2017-04-22 00:06:17 +08:00
    stancaohua
        1
    stancaohua  
       2017-04-21 18:17:39 +08:00
    guokeke
        2
    guokeke  
       2017-04-21 18:19:29 +08:00
    61882328
        3
    61882328  
    OP
       2017-04-21 18:59:28 +08:00
    谢谢。。我试下。
    yezhiye
        4
    yezhiye  
       2017-04-21 22:12:43 +08:00
    不尝试下无头浏览器吗……
    wangxiaodong
        5
    wangxiaodong  
       2017-04-21 22:49:16 +08:00
    mingyun
        6
    mingyun  
       2017-04-22 00:06:17 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2090 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 01:41 · PVG 09:41 · LAX 18:41 · JFK 21:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.