在Ubuntu服务器上运行Python Selenium脚本

时间:2018-01-26 20:03:25

标签: python-3.x selenium ubuntu selenium-webdriver ubuntu-server

我有一个完美适用于ubuntu桌面系统的脚本。该脚本使用无头firefox来上网并做一些事情。但是当我尝试通过ssh在Ubuntu服务器上运行它时,它会卡住并且什么也不做。当我用键盘中断脚本时,我会看到下面的回溯。

服务器位于DigitalOcean上,内存为1Gb。

所以,我有两个问题:

1)我需要做什么才能在Ubuntu服务器上运行脚本?

2)如何启动脚本以使其全天候运行并且我可以离开终端窗口?

Traceback (most recent call last):

   File "cl_mailer.py", line 123, in <module>

    main()

  File "cl_mailer.py", line 55, in main

    d.get(category)

  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote
/webdriver.py", line 324, in get

    self.execute(Command.GET, {'url': url})

  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 310, in execute

    response = self.command_executor.execute(driver_command, params)

  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/remote_connection.py", line 466, in execute

    return self._request(command_info[0], url, body=data)

  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/remote_connection.py", line 490, in _request

    resp = self._conn.getresponse()

  File "/usr/lib/python3.5/http/client.py", line 1197, in getresponse

    response.begin()

  File "/usr/lib/python3.5/http/client.py", line 297, in begin

    version, status, reason = self._read_status()

  File "/usr/lib/python3.5/http/client.py", line 258, in _read_status

    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")

  File "/usr/lib/python3.5/socket.py", line 575, in readinto

    return self._sock.recv_into(b)

KeyboardInterrupt

0 个答案:

没有答案