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

[求助] Python 调用 phantomjs 老是因为 Out of memory 被 kill

  •  
  •   goodryb · 2017-12-01 11:32:01 +08:00 · 3004 次点击
    这是一个创建于 2337 天前的主题,其中的信息可能已经有所发展或是发生改变。
    第 1 条附言  ·  2017-12-06 16:14:53 +08:00
    切换到 chrome headless 后就没问题了,内存占用很小

    确认是 phantomjs 的锅
    12 条回复    2017-12-01 20:35:01 +08:00
    janxin
        1
    janxin  
       2017-12-01 11:41:15 +08:00
    内存太小了?
    goodryb
        2
    goodryb  
    OP
       2017-12-01 11:44:16 +08:00
    @janxin #1 1.6G 不算小吧,程序启动了可以运行几个小时,内存一直增加,然后就被 kill 了
    neoblackcap
        3
    neoblackcap  
       2017-12-01 11:45:05 +08:00
    phantomjs OOM 很正常,用 chrome headless mode。作者都是这样说
    wzwwzw
        4
    wzwwzw  
       2017-12-01 13:01:16 +08:00
    为什么不用 chrome headless 呢。
    hahastudio
        5
    hahastudio  
       2017-12-01 13:05:20 +08:00
    一定要用 phantomjs 的话,可以爬几个页面重启一下 phantomjs
    holyghost
        6
    holyghost  
       2017-12-01 13:09:00 +08:00
    我已经换到 chrome headless 了
    a7a2
        7
    a7a2  
       2017-12-01 13:25:07 +08:00
    建议使用 chromedriver,phantomjs 就很容易被识别。。。
    goodryb
        8
    goodryb  
    OP
       2017-12-01 15:07:46 +08:00
    @neoblackcap #3
    @wzwwzw #4
    @holyghost #6
    @a7a2 #7

    好吧,看来我用到的工具落后了,已经更换到了 chrome headless,今天跑一跑,看看情况


    @hahastudio #5 这个有点麻烦,解决方法不是太优雅
    gouchaoer
        9
    gouchaoer  
       2017-12-01 15:17:02 +08:00
    新的就用 chrome headless,老的懒得切就继续 phantomjs 咯
    Tunar
        10
    Tunar  
       2017-12-01 15:48:01 +08:00 via Android
    作者不是溜了么。。
    BiggerLonger
        11
    BiggerLonger  
       2017-12-01 16:17:16 +08:00
    chrome 沒有像 phantomjs 那樣的 web server 模塊吧?
    goodryb
        12
    goodryb  
    OP
       2017-12-01 20:35:01 +08:00
    @gouchaoer #9 个人用,所以切换比较方便

    @Tunar #10 不太清楚呢

    @BiggerLonger #11 我感觉两种方式差不多,chrome 需要一个额外的 chromedriver
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   984 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 21:21 · PVG 05:21 · LAX 14:21 · JFK 17:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.