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

Seleium+chromedriver 怎么解决内存问题

  •  
  •   kaishui00 · Sep 24, 2019 · 3930 views
    This topic created in 2558 days ago, the information mentioned may be changed or developed.

    长时间爬取(三百次)左右,就出现内存不足,浏览器崩溃。有什么好的办法吗?

    8 replies  •  2019-09-25 22:54:31 +08:00
    weakiwi
        1
    weakiwi  
       Sep 24, 2019
    试试 selenoid ?或者直接用 chromecdp
    ml1344677
        2
    ml1344677  
       Sep 24, 2019
    300 次是 300 次访问? 用了无头模式吗 加载了图片吗 完全不清楚你是什么情况
    arrow8899
        3
    arrow8899  
       Sep 24, 2019
    开了 300 个 tab 吗,你是不是忘记关闭页面了
    Leigg
        4
    Leigg  
       Sep 24, 2019 via Android
    得关了重启。
    Leigg
        5
    Leigg  
       Sep 24, 2019 via Android
    遇到过,没查到什么原因。只能在定时重启。
    kaishui00
        6
    kaishui00  
    OP
       Sep 25, 2019
    @ml1344677
    @arrow8899

    无头模式,一个标签,300 次访问,加载图片了,因为用到验证码
    ClericPy
        7
    ClericPy  
       Sep 25, 2019
    这问题貌似已经很多年了, 官方 issue 没说什么吗
    之前也是各种内存爆裂的问题才试了各种 driver, 后来还试过一个叫 ghost.py 的坑, 最后不得不硬撸 cdp 了, 反正一共就那么几个请求, 也没必要上 puppteer 或者 pyppteer
    ClericPy
        8
    ClericPy  
       Sep 25, 2019
    我自己调试 cdp 的时候倒是发现经常有 close tab 失败的情况, 或者杀子进程没关 fd 之类的小问题导致僵尸进程吃内存

    你一个标签, 是打开一个又关上吗, 我记得 Chrome 既有关闭最近打开的功能, 默认的 history 深度又很高... 不确定你到底什么坑
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2361 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 10:37 · PVG 18:37 · LAX 03:37 · JFK 06:37
    ♥ Do have faith in what you're doing.