推荐学习书目
› 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
qazwsxkevin
V2EX  ›  Python

selenium+chrome, headless 模式启动慢的原因?

  •  
  •   qazwsxkevin · Jun 6, 2019 · 3993 views
    This topic created in 2671 days ago, the information mentioned may be changed or developed.
            options = webdriver.ChromeOptions()
            options.add_argument('--headless')
            options.add_argument('--disable-gpu')
            # driver = webdriver.Chrome()
            driver = webdriver.Chrome(options=options)
            # driver.maximize_window()
    
            # 清除浏览器 cookies
            # cookies = driver.get_cookies()
            # print(f"main: cookies = {cookies}")
            # driver.delete_all_cookies()
    
            driver.get(TarGeturl)
            print("Get OK")
    

    这个问题有人曾经问过( https://www.v2ex.com/t/514156),
    但是没解决问题的方法。。。
    现在我也遇上了这个问题,也尝试过把 driver.chrome()的 cookies,缓存什么的都清干净了,
    如果不用 headless 模式,页面几乎是瞬间获取到了,drivers.chrome()有 bug?
    大家有遇到过这种情况么?

    1 replies  •  2019-11-01 18:12:48 +08:00
    VVTA
        1
    VVTA  
       Nov 1, 2019
    我是 chrome75 版本都正常,升级到 77,78 后。处理第一次启动(设置 user-dir 时候)超快,后面都要 20~30 秒。疯了,删掉 user-dir 目录,让 chrome 从干净系统启动又正常。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2504 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 15:43 · PVG 23:43 · LAX 08:43 · JFK 11:43
    ♥ Do have faith in what you're doing.