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

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

  •  
  •   qazwsxkevin · 2019-06-06 11:46:50 +08:00 · 2748 次点击
    这是一个创建于 1783 天前的主题,其中的信息可能已经有所发展或是发生改变。
            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 条回复    2019-11-01 18:12:48 +08:00
    VVTA
        1
    VVTA  
       2019-11-01 18:12:48 +08:00
    我是 chrome75 版本都正常,升级到 77,78 后。处理第一次启动(设置 user-dir 时候)超快,后面都要 20~30 秒。疯了,删掉 user-dir 目录,让 chrome 从干净系统启动又正常。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5467 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 06:49 · PVG 14:49 · LAX 23:49 · JFK 02:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.