I’m writing a web app that uses Selenium to screen-scrape another website. This screen-scraping only happens once a day, so I’d rather not leave Selenium and Xvfb running all the time.
I’m trying to figure out how to start Xvfb and Selenium from Python, and then stop them once the screen-scraping’s done.
If I was doing it manually, I’d start them at the command line, and hit CTRL C to stop them. I’m trying to do the same thing from Python.
I seem to be able to successfully start Xvfb like this:
xvfb = Popen('Xvfb :99 -nolisten tcp', shell=True)
But when I’ve tried to terminate it:
xvfb.terminate()
and then tried to start it again (by repeating my initial command), it tells me it’s already running.
xvfb.wait()
afterxvfb.terminate()
. Failing that, tryxvfb.kill()
. – Quota