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

Python selenium-webdriver 服务器关闭后, webdriver 不可用

  •  
  •   DOUWH · 2019-09-13 11:12:27 +08:00 · 2834 次点击
    这是一个创建于 1687 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近使用到 selenium 做一些数据采集,想放到服务器上后台运行,结果出现了一些错误!还请大佬们来指点!

    问题描述: nohup 后台运行 python,退出服务器,selenium 跟着也退出了 selenium.common.exceptions.WebDriverException: Message: chrome not reachable (Session info: headless chrome=77.0.3865.75)

    运行命令:nohup python -u python.py > run.log 2>&1 &
    selenium-webdriver 启动代码:
    	service = Service('/home/chromedriver')
    	service.command_line_args()
    	service.start()
    	options = webdriver.ChromeOptions()
    	options.add_argument('--headless')
    	options.add_argument('--no-sandbox')
    	options.add_argument('--disable-dev-shm-usage')
    	options.add_argument('--disable-gpu')
    	prefs = {"profile.managed_default_content_settings.images": 2}
    	options.add_experimental_option("prefs", prefs)
    	driver = webdriver.Chrome(options=options)
    

    还请各位大佬看下问题出在哪里。

    3 条回复    2019-09-13 11:22:22 +08:00
    hfutzj
        1
    hfutzj  
       2019-09-13 11:16:38 +08:00 via Android
    服务器后台运行的我一般用 screen
    ysc3839
        2
    ysc3839  
       2019-09-13 11:18:28 +08:00 via Android
    建议使用 screen 或 tmux。
    DOUWH
        3
    DOUWH  
    OP
       2019-09-13 11:22:22 +08:00
    @hfutzj
    @ysc3839

    好的两位大哥,我尝试一下
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2885 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 11:40 · PVG 19:40 · LAX 04:40 · JFK 07:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.